Files
Checkmate/Client/src/Features/UI/uiSlice.js
T

53 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-08-20 17:10:03 -04:00
import { createSlice } from "@reduxjs/toolkit";
2024-08-20 17:34:54 -04:00
// Initial state for UI settings.
// Add more settings as needed (e.g., theme preferences, user settings)
2024-08-20 17:10:03 -04:00
const initialState = {
2024-08-20 18:40:03 -04:00
monitors: {
rowsPerPage: 10,
2024-08-20 18:40:03 -04:00
},
team: {
2024-08-20 17:10:03 -04:00
rowsPerPage: 5,
},
sidebar: {
collapsed: false,
},
2024-08-28 22:14:55 -04:00
mode: "light",
greeting: { index: 0, lastUpdate: null },
2024-09-12 11:36:22 +08:00
timezone: "America/Toronto",
2024-08-20 17:10:03 -04:00
};
const uiSlice = createSlice({
name: "ui",
initialState,
reducers: {
2024-08-20 17:27:07 -04:00
setRowsPerPage: (state, action) => {
const { table, value } = action.payload;
if (state[table]) {
state[table].rowsPerPage = value;
}
2024-08-20 17:18:02 -04:00
},
toggleSidebar: (state) => {
state.sidebar.collapsed = !state.sidebar.collapsed;
},
2024-08-28 22:14:55 -04:00
setMode: (state, action) => {
state.mode = action.payload;
},
setGreeting(state, action) {
state.greeting.index = action.payload.index;
state.greeting.lastUpdate = action.payload.lastUpdate;
},
2024-09-12 11:36:22 +08:00
setTimezone(state, action) {
state.timezone = action.payload.timezone;
},
2024-08-20 17:10:03 -04:00
},
});
export default uiSlice.reducer;
2024-09-12 11:36:22 +08:00
export const {
setRowsPerPage,
toggleSidebar,
setMode,
setGreeting,
setTimezone,
} = uiSlice.actions;