summaryrefslogtreecommitdiff
path: root/client/src/slices/uiSlice.ts
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2024-10-05 11:06:50 -0700
committerMichael Hunteman <michael@huntm.net>2024-10-05 11:06:50 -0700
commitaacf26f374f48b88d532d1528d9d07aabf537610 (patch)
treea777bb304e16e9bc5bf63f0b91c2ce8c727a7090 /client/src/slices/uiSlice.ts
parent80c6cc650601613db580c154e8d50e5a13b69f03 (diff)
Add calendar inviteHEADmaster
Diffstat (limited to 'client/src/slices/uiSlice.ts')
-rw-r--r--client/src/slices/uiSlice.ts42
1 files changed, 42 insertions, 0 deletions
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;