fix: session related bugs
This commit is contained in:
@@ -43,6 +43,7 @@ const CuentaTabs: FC = () => {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<AnimatePresence
|
<AnimatePresence
|
||||||
|
initial={false}
|
||||||
mode='wait'
|
mode='wait'
|
||||||
>
|
>
|
||||||
{currentTab === 'login' && (
|
{currentTab === 'login' && (
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user