mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-11 22:06:29 +02:00
Fix login not updating redux store by reloading whole page
This commit is contained in:
@@ -22,6 +22,7 @@ export const auth = createSlice({
|
||||
state.jwt = action.payload.jwt
|
||||
},
|
||||
logoutUser: (state) => {
|
||||
// Unused, just reload page :/
|
||||
state.id = 0
|
||||
state.jwt = ""
|
||||
},
|
||||
|
@@ -3,9 +3,6 @@ import { PayloadAction, createSlice } from "@reduxjs/toolkit"
|
||||
import { StateRequest, elementFetch } from "./utils"
|
||||
import { VolunteerLogin } from "../services/volunteers"
|
||||
import { setJWT } from "../services/auth"
|
||||
import { AppDispatch } from "."
|
||||
import { setCurrentUser } from "./auth"
|
||||
import { fetchVolunteerNotifsSet } from "./volunteerNotifsSet"
|
||||
import { volunteerLogin } from "../services/volunteersAccessors"
|
||||
|
||||
type StateVolunteer = { entity?: VolunteerLogin } & StateRequest
|
||||
@@ -41,9 +38,9 @@ export const fetchVolunteerLogin = elementFetch<VolunteerLogin, Parameters<typeo
|
||||
getSuccess,
|
||||
getFailure,
|
||||
undefined,
|
||||
(login: VolunteerLogin, dispatch: AppDispatch) => {
|
||||
(login: VolunteerLogin) => {
|
||||
setJWT(login.jwt, login.id)
|
||||
dispatch(setCurrentUser(login))
|
||||
dispatch(fetchVolunteerNotifsSet(login.jwt, login.id, {}))
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
location?.reload()
|
||||
}
|
||||
)
|
||||
|
Reference in New Issue
Block a user