Fix login not updating redux store by reloading whole page

This commit is contained in:
pikiou
2022-02-16 02:44:23 +01:00
parent 4b2a68174b
commit 140891c4c0
5 changed files with 33 additions and 38 deletions

View File

@@ -22,6 +22,7 @@ export const auth = createSlice({
state.jwt = action.payload.jwt
},
logoutUser: (state) => {
// Unused, just reload page :/
state.id = 0
state.jwt = ""
},

View File

@@ -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()
}
)