diff options
Diffstat (limited to 'client/src/slices')
-rw-r--r-- | client/src/slices/auth/adminSlice.ts | 4 | ||||
-rw-r--r-- | client/src/slices/auth/guestSlice.ts | 4 | ||||
-rw-r--r-- | client/src/slices/snackbarSlice.ts | 32 |
3 files changed, 34 insertions, 6 deletions
diff --git a/client/src/slices/auth/adminSlice.ts b/client/src/slices/auth/adminSlice.ts index cc2205e..3007059 100644 --- a/client/src/slices/auth/adminSlice.ts +++ b/client/src/slices/auth/adminSlice.ts @@ -23,7 +23,5 @@ const adminSlice = createSlice({ }); export const { setAdmin } = adminSlice.actions; - -export default adminSlice.reducer; - export const selectGuests = (state: RootState) => state.admin.guests; +export default adminSlice.reducer; diff --git a/client/src/slices/auth/guestSlice.ts b/client/src/slices/auth/guestSlice.ts index fb4afaf..238781f 100644 --- a/client/src/slices/auth/guestSlice.ts +++ b/client/src/slices/auth/guestSlice.ts @@ -23,7 +23,5 @@ const guestSlice = createSlice({ }); export const { setGuest } = guestSlice.actions; - -export default guestSlice.reducer; - export const selectGuest = (state: RootState) => state.guest.guest; +export default guestSlice.reducer; diff --git a/client/src/slices/snackbarSlice.ts b/client/src/slices/snackbarSlice.ts new file mode 100644 index 0000000..eca9575 --- /dev/null +++ b/client/src/slices/snackbarSlice.ts @@ -0,0 +1,32 @@ +import { createSlice } from '@reduxjs/toolkit'; +import type { RootState } from '../store'; + +export interface SnackbarState { + open: boolean; + message: string; + severity?: 'success' | 'error'; +} + +const initialState: SnackbarState = { + open: false, + message: '', +}; + +export const snackbarSlice = createSlice({ + name: 'snackbar', + initialState, + reducers: { + open(state, action) { + state.open = true; + state.message = action.payload.message; + state.severity = action.payload.severity; + }, + close(state) { + state.open = false; + }, + }, +}); + +export const { open, close } = snackbarSlice.actions; +export const selectSnackbarState = (state: RootState) => state.snackbar; +export default snackbarSlice.reducer; |