summaryrefslogtreecommitdiff
path: root/extension/react-app/src/redux/slices/uiStateSlice.ts
blob: d34596c903744eed716cbd97f541c1b82fe1ea6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { createSlice } from "@reduxjs/toolkit";

export const uiStateSlice = createSlice({
  name: "uiState",
  initialState: {
    bottomMessage: undefined,
    bottomMessageCloseTimeout: undefined,
    showDialog: false,
    dialogMessage: "",
    dialogEntryOn: false,
    displayBottomMessageOnBottom: true,
  },
  reducers: {
    setBottomMessage: (state, action) => {
      state.bottomMessage = action.payload;
    },
    setBottomMessageCloseTimeout: (state, action) => {
      if (state.bottomMessageCloseTimeout) {
        clearTimeout(state.bottomMessageCloseTimeout);
      }
      state.bottomMessageCloseTimeout = action.payload;
    },
    setDialogMessage: (state, action) => {
      state.dialogMessage = action.payload;
    },
    setDialogEntryOn: (state, action) => {
      state.dialogEntryOn = action.payload;
    },
    setShowDialog: (state, action) => {
      state.showDialog = action.payload;
    },
    setDisplayBottomMessageOnBottom: (state, action) => {
      state.displayBottomMessageOnBottom = action.payload;
    },
  },
});

export const {
  setBottomMessage,
  setBottomMessageCloseTimeout,
  setDialogMessage,
  setDialogEntryOn,
  setShowDialog,
  setDisplayBottomMessageOnBottom,
} = uiStateSlice.actions;
export default uiStateSlice.reducer;