Skip to content

Commit

Permalink
Fix some reducers in user slice
Browse files Browse the repository at this point in the history
migrate to TS to have help from compiler
  • Loading branch information
Tristan-WorkGH committed Jul 8, 2024
1 parent 74326df commit b62e109
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/redux/slices/User.js → src/redux/slices/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ import {
RESET_AUTHENTICATION_ROUTER_ERROR,
SHOW_AUTH_INFO_LOGIN,
} from '@gridsuite/commons-ui';
import { User } from 'oidc-client';
import { SliceCaseReducers } from '@reduxjs/toolkit';

const initialState = {
export type UserState = {
user: User | null;
signInCallbackError: string | null;
authenticationRouterError: any;
showAuthenticationRouterLogin: boolean;
};

const initialState: UserState = {
user: null,
signInCallbackError: null,
authenticationRouterError: null,
Expand All @@ -27,7 +36,7 @@ const initialState = {

// Reducers

const reducers = {
const reducers: SliceCaseReducers<UserState> = {
[USER]: (state, action) => {
// TODO: GridSuite: Should be payload
state.user = action.payload.user;
Expand All @@ -39,15 +48,18 @@ const reducers = {
},

[UNAUTHORIZED_USER_INFO]: (state, action) => {
state.authenticationRouterError = action.authenticationRouterError;
state.authenticationRouterError =
action.payload.authenticationRouterError;
},

[LOGOUT_ERROR]: (state, action) => {
state.authenticationRouterError = action.authenticationRouterError;
state.authenticationRouterError =
action.payload.authenticationRouterError;
},

[USER_VALIDATION_ERROR]: (state, action) => {
state.authenticationRouterError = action.authenticationRouterError;
state.authenticationRouterError =
action.payload.authenticationRouterError;
},

[RESET_AUTHENTICATION_ROUTER_ERROR]: (state, action) => {
Expand Down

0 comments on commit b62e109

Please sign in to comment.