From 0b89d0c89bdf6cf827390ee3ecb481db57e31242 Mon Sep 17 00:00:00 2001 From: franco sanchez Date: Mon, 20 May 2024 19:17:14 -0300 Subject: [PATCH] chore: minor changes --- src/hooks/useAccountActions.tsx | 35 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/hooks/useAccountActions.tsx b/src/hooks/useAccountActions.tsx index bb12757..38b8bf3 100644 --- a/src/hooks/useAccountActions.tsx +++ b/src/hooks/useAccountActions.tsx @@ -1,19 +1,22 @@ -import { useNavigate } from 'react-router-dom'; +// import { useNavigate } from 'react-router-dom'; import { + // getAuth, signOut, reauthenticateWithCredential, GoogleAuthProvider, + // signInWithCredential, } from 'firebase/auth'; import { logIn } from '@services/auth/config'; import { useAuth } from '@contexts/AuthContext'; -import { useDeleteAccount } from '@hooks/querys'; +// import { useDeleteAccount } from '@hooks/queries'; export function useAccountActions() { - const navigate = useNavigate(); + // const navigate = useNavigate(); const { currentUser } = useAuth(); - const uid = currentUser?.uid; - const { mutate } = useDeleteAccount(); + // const uid = currentUser?.uid; + // const { mutate } = useDeleteAccount(); + // const auth = getAuth(); async function logOut() { try { @@ -23,24 +26,28 @@ export function useAccountActions() { console.error('Error al cerrar sesiĆ³n:', error); } } + // const token = await currentUser?.getIdToken(); + // const accessToken = await currentUser?.getIdToken(true); + // const credential = GoogleAuthProvider.credential(token, accessToken); + // await reauthenticateWithCredential(currentUser, credential); async function deleteAccount() { try { if (currentUser) { - // const idToken = await currentUser?.; - // const credential = GoogleAuthProvider.credential(idToken); - // await reauthenticateWithCredential(currentUser, credential); - - await mutate(uid); // Elimina la cuenta y sus libros de la base de datos - await currentUser?.delete(); // Elimina la cuenta de Firebase - await signOut(logIn); - await window.localStorage.removeItem('app_tk'); - await navigate('/', { replace: true }); + const idToken = await currentUser?.getIdToken(); + const credential = GoogleAuthProvider.credential(idToken); + await reauthenticateWithCredential(currentUser, credential); + await currentUser?.delete(); } } catch (error) { console.error('Error al borrar la cuenta:', error); } } + // await mutate(uid); // Elimina la cuenta y sus libros de la base de datos + // await currentUser?.delete(); // Elimina la cuenta de Firebase + // await signOut(logIn); + // await window.localStorage.removeItem('app_tk'); + // await navigate('/', { replace: true }); return { logOut, deleteAccount }; }