-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslice.ts
37 lines (34 loc) · 835 Bytes
/
slice.ts
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
import { createSlice } from "@reduxjs/toolkit";
interface IinitialState {
isOpen: boolean;
loading: boolean;
openSidebar: boolean;
tableData: any[];
}
const initialState: IinitialState = {
isOpen: false,
loading: false,
openSidebar: false,
tableData: [],
};
export const adminSlice = createSlice({
name: "admin",
initialState,
reducers: {
setDialog: (state, action) => {
state.isOpen = action.payload;
},
setLoading: (state, action) => {
state.loading = action.payload;
},
setOpenSidebar: (state) => {
state.openSidebar = !state.openSidebar;
},
setTableData: (state, action) => {
state.tableData = action.payload;
},
},
});
export default adminSlice.reducer;
export const { setDialog, setLoading, setOpenSidebar, setTableData } =
adminSlice.actions;