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/uiSlice.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 client/src/slices/uiSlice.ts (limited to 'client/src/slices/uiSlice.ts') 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