summaryrefslogtreecommitdiff
path: root/client/src/slices
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/slices')
-rw-r--r--client/src/slices/snackbarSlice.ts33
-rw-r--r--client/src/slices/uiSlice.ts42
2 files changed, 42 insertions, 33 deletions
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;