fix: session related bugs

This commit is contained in:
2024-02-08 15:37:57 -06:00
parent 9878ca7f1c
commit e105edbbee
5 changed files with 10 additions and 9 deletions
+1
View File
@@ -43,6 +43,7 @@ const CuentaTabs: FC = () => {
})} })}
> >
<AnimatePresence <AnimatePresence
initial={false}
mode='wait' mode='wait'
> >
{currentTab === 'login' && ( {currentTab === 'login' && (
+3 -3
View File
@@ -35,7 +35,7 @@ const UpdateUserName: FC = () => {
dispatch(addAlert({ dispatch(addAlert({
id: nanoid(), id: nanoid(),
title: 'Nombre actualizado', title: 'Nombre actualizado',
message: 'Ahora puedes iniciar sesión', message: 'Se actualizo correctamente el nombre',
severity: 'success' severity: 'success'
})) }))
} catch (error) { } catch (error) {
@@ -62,13 +62,13 @@ const UpdateUserName: FC = () => {
}) })
useEffect(() => { useEffect(() => {
if (status !== 'idle' && session !== undefined) { if (status === 'idle' && session !== undefined && user !== undefined) {
formik.setValues({ formik.setValues({
name: user?.name ?? '' name: user?.name ?? ''
}) })
.catch(console.error) .catch(console.error)
} }
}, [status, session]) }, [status, session, user])
if (status !== 'idle' || session === undefined) { if (status !== 'idle' || session === undefined) {
// TODO: Replace with Skeleton // TODO: Replace with Skeleton
+3 -3
View File
@@ -73,7 +73,7 @@ const EquipoPage: FC = async () => {
className={cx(card({ variant: 'retro' }).media, center())} className={cx(card({ variant: 'retro' }).media, center())}
> >
<NextImage <NextImage
src={user.prefs.profilePicture ?? '/images/EntGamers.png'} src={user.prefs.profilePicture !== undefined && user.prefs.profilePicture.trim() !== '' ? user.prefs.profilePicture.trim() : '/images/EntGamers.png'}
alt={user.name !== '' ? user.name : `Usuario ${index + 1} avatar`} alt={user.name !== '' ? user.name : `Usuario ${index + 1} avatar`}
width={120} width={120}
height={120} height={120}
@@ -135,7 +135,7 @@ const EquipoPage: FC = async () => {
className={cx(card({ variant: 'retro' }).media, center())} className={cx(card({ variant: 'retro' }).media, center())}
> >
<NextImage <NextImage
src={user.prefs.profilePicture ?? '/images/EntGamers.png'} src={user.prefs.profilePicture !== undefined && user.prefs.profilePicture.trim() !== '' ? user.prefs.profilePicture.trim() : '/images/EntGamers.png'}
alt={user.name !== '' ? user.name : `Usuario ${index + 1} avatar`} alt={user.name !== '' ? user.name : `Usuario ${index + 1} avatar`}
width={120} width={120}
height={120} height={120}
@@ -197,7 +197,7 @@ const EquipoPage: FC = async () => {
className={cx(card({ variant: 'retro' }).media, center())} className={cx(card({ variant: 'retro' }).media, center())}
> >
<NextImage <NextImage
src={user.prefs.profilePicture ?? '/images/EntGamers.png'} src={user.prefs.profilePicture !== undefined && user.prefs.profilePicture.trim() !== '' ? user.prefs.profilePicture.trim() : '/images/EntGamers.png'}
alt={user.name !== '' ? user.name : `Usuario ${index + 1} avatar`} alt={user.name !== '' ? user.name : `Usuario ${index + 1} avatar`}
width={120} width={120}
height={120} height={120}
+2 -2
View File
@@ -6,7 +6,7 @@ import { useAppSelector } from './useAppSelector'
type UseSession = (redirect?: string) => SessionState type UseSession = (redirect?: string) => SessionState
const useSession: UseSession = (redirect?: string) => { const useSession: UseSession = (redirect?: string) => {
const { status, session } = useAppSelector((state) => state.session) const { status, session, user } = useAppSelector((state) => state.session)
const router = useRouter() const router = useRouter()
useEffect(() => { useEffect(() => {
@@ -15,7 +15,7 @@ const useSession: UseSession = (redirect?: string) => {
} }
}, [status, session]) }, [status, session])
return { status, session } return { status, session, user }
} }
export default useSession export default useSession
+1 -1
View File
@@ -32,7 +32,7 @@ const sessionSlice = createSlice({
setCurrentUser: (state, action: PayloadAction<SessionState['user']>) => { setCurrentUser: (state, action: PayloadAction<SessionState['user']>) => {
return { return {
...state, ...state,
userPreferences: action.payload user: action.payload
} }
} }
} }