doc: add initialState and authSlice in auth file
This commit is contained in:
1 parent
dc68b05303
commit
6320ee8578
1 file changed
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
const initialState = {
|
||||||
|
user: {},
|
||||||
|
isAuthenticated: false,
|
||||||
|
sessionId: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
const authSlice = createSlice({
|
||||||
|
name: 'user',
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
setUser: (state, action) => {
|
||||||
|
state.user = action.payload;
|
||||||
|
state.isAuthenticated = true;
|
||||||
|
state.sessionId = localStorage.getItem('session_id');
|
||||||
|
|
||||||
|
localStorage.setItem('accountId', action.payload.id);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { setUser } = authSlice.actions;
|
||||||
|
|
||||||
|
export default authSlice.reducer;
|
||||||
Reference in new issue
Block a user