fix: session related bugs
This commit is contained in:
@@ -43,6 +43,7 @@ const CuentaTabs: FC = () => {
|
||||
})}
|
||||
>
|
||||
<AnimatePresence
|
||||
initial={false}
|
||||
mode='wait'
|
||||
>
|
||||
{currentTab === 'login' && (
|
||||
|
||||
@@ -35,7 +35,7 @@ const UpdateUserName: FC = () => {
|
||||
dispatch(addAlert({
|
||||
id: nanoid(),
|
||||
title: 'Nombre actualizado',
|
||||
message: 'Ahora puedes iniciar sesión',
|
||||
message: 'Se actualizo correctamente el nombre',
|
||||
severity: 'success'
|
||||
}))
|
||||
} catch (error) {
|
||||
@@ -62,13 +62,13 @@ const UpdateUserName: FC = () => {
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (status !== 'idle' && session !== undefined) {
|
||||
if (status === 'idle' && session !== undefined && user !== undefined) {
|
||||
formik.setValues({
|
||||
name: user?.name ?? ''
|
||||
})
|
||||
.catch(console.error)
|
||||
}
|
||||
}, [status, session])
|
||||
}, [status, session, user])
|
||||
|
||||
if (status !== 'idle' || session === undefined) {
|
||||
// TODO: Replace with Skeleton
|
||||
|
||||
@@ -73,7 +73,7 @@ const EquipoPage: FC = async () => {
|
||||
className={cx(card({ variant: 'retro' }).media, center())}
|
||||
>
|
||||
<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`}
|
||||
width={120}
|
||||
height={120}
|
||||
@@ -135,7 +135,7 @@ const EquipoPage: FC = async () => {
|
||||
className={cx(card({ variant: 'retro' }).media, center())}
|
||||
>
|
||||
<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`}
|
||||
width={120}
|
||||
height={120}
|
||||
@@ -197,7 +197,7 @@ const EquipoPage: FC = async () => {
|
||||
className={cx(card({ variant: 'retro' }).media, center())}
|
||||
>
|
||||
<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`}
|
||||
width={120}
|
||||
height={120}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useAppSelector } from './useAppSelector'
|
||||
type UseSession = (redirect?: string) => SessionState
|
||||
|
||||
const useSession: UseSession = (redirect?: string) => {
|
||||
const { status, session } = useAppSelector((state) => state.session)
|
||||
const { status, session, user } = useAppSelector((state) => state.session)
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
@@ -15,7 +15,7 @@ const useSession: UseSession = (redirect?: string) => {
|
||||
}
|
||||
}, [status, session])
|
||||
|
||||
return { status, session }
|
||||
return { status, session, user }
|
||||
}
|
||||
|
||||
export default useSession
|
||||
|
||||
@@ -32,7 +32,7 @@ const sessionSlice = createSlice({
|
||||
setCurrentUser: (state, action: PayloadAction<SessionState['user']>) => {
|
||||
return {
|
||||
...state,
|
||||
userPreferences: action.payload
|
||||
user: action.payload
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user