visuddhinanda 2 lat temu
rodzic
commit
f0eab3aa9d
1 zmienionych plików z 7 dodań i 1 usunięć
  1. 7 1
      dashboard/src/reducers/current-user.ts

+ 7 - 1
dashboard/src/reducers/current-user.ts

@@ -44,6 +44,7 @@ export interface IUser {
 
 interface IState {
   payload?: IUser;
+  guest?: boolean;
 }
 
 const initialState: IState = {};
@@ -60,10 +61,13 @@ export const slice = createSlice({
       state.payload = undefined;
       remove();
     },
+    guest: (state, action: PayloadAction<boolean>) => {
+      state.guest = action.payload;
+    },
   },
 });
 
-export const { signIn, signOut } = slice.actions;
+export const { signIn, signOut, guest } = slice.actions;
 
 export const isRoot = (state: RootState): boolean =>
   state.currentUser.payload?.roles.includes(ROLE_ROOT) || false;
@@ -71,5 +75,7 @@ export const isAdministrator = (state: RootState): boolean =>
   state.currentUser.payload?.roles.includes(ROLE_ADMINISTRATOR) || false;
 export const currentUser = (state: RootState): IUser | undefined =>
   state.currentUser.payload;
+export const isGuest = (state: RootState): boolean | undefined =>
+  state.currentUser.guest;
 
 export default slice.reducer;