From aacf26f374f48b88d532d1528d9d07aabf537610 Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Sat, 5 Oct 2024 11:06:50 -0700 Subject: Add calendar invite --- client/src/slices/snackbarSlice.ts | 33 ------------------------------ client/src/slices/uiSlice.ts | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 33 deletions(-) delete mode 100644 client/src/slices/snackbarSlice.ts create mode 100644 client/src/slices/uiSlice.ts (limited to 'client/src/slices') diff --git a/client/src/slices/snackbarSlice.ts b/client/src/slices/snackbarSlice.ts deleted file mode 100644 index 82532ec..0000000 --- a/client/src/slices/snackbarSlice.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { createSlice } from '@reduxjs/toolkit'; -import type { AlertColor } from '@mui/material/Alert/Alert'; -import type { RootState } from '../store'; - -export interface SnackbarState { - open: boolean; - message: string; - severity?: AlertColor; -} - -const initialState: SnackbarState = { - open: false, - message: '', -}; - -export const snackbarSlice = createSlice({ - name: 'snackbar', - initialState, - reducers: { - showSnackbar: (state, action) => { - state.open = true; - state.message = action.payload.message; - state.severity = action.payload.severity; - }, - hideSnackbar: (state) => { - state.open = false; - }, - }, -}); - -export const { showSnackbar, hideSnackbar } = snackbarSlice.actions; -export const selectSnackbarState = (state: RootState) => state.snackbar; -export default snackbarSlice.reducer; diff --git a/client/src/slices/uiSlice.ts b/client/src/slices/uiSlice.ts new file mode 100644 index 0000000..ac461d1 --- /dev/null +++ b/client/src/slices/uiSlice.ts @@ -0,0 +1,42 @@ +import { createSlice } from '@reduxjs/toolkit'; +import type { AlertColor } from '@mui/material/Alert/Alert'; +import type { RootState } from '../store'; + +export interface UIState { + snackbarOpen: boolean; + message: string; + severity?: AlertColor; + dialogOpen: boolean; +} + +const initialState: UIState = { + snackbarOpen: false, + message: '', + dialogOpen: false, +}; + +export const uiSlice = createSlice({ + name: 'ui', + initialState, + reducers: { + showSnackbar: (state, action) => { + state.snackbarOpen = true; + state.message = action.payload.message; + state.severity = action.payload.severity; + }, + hideSnackbar: (state) => { + state.snackbarOpen = false; + }, + showDialog: (state) => { + state.dialogOpen = true; + }, + hideDialog: (state) => { + state.dialogOpen = false; + }, + }, +}); + +export const { showSnackbar, hideSnackbar, showDialog, hideDialog } = + uiSlice.actions; +export const selectUIState = (state: RootState) => state.ui; +export default uiSlice.reducer; -- cgit v1.2.3