diff --git a/Client/src/Components/Sidebar/index.jsx b/Client/src/Components/Sidebar/index.jsx index 38baa33ec..34221c406 100644 --- a/Client/src/Components/Sidebar/index.jsx +++ b/Client/src/Components/Sidebar/index.jsx @@ -19,6 +19,7 @@ import { useLocation, useNavigate } from "react-router"; import { useTheme } from "@emotion/react"; import { useDispatch, useSelector } from "react-redux"; import { clearAuthState } from "../../Features/Auth/authSlice"; +import { toggleSidebar } from "../../Features/UI/uiSlice"; import { clearUptimeMonitorState } from "../../Features/UptimeMonitors/uptimeMonitorsSlice"; import Avatar from "../Avatar"; import LockSvg from "../../assets/icons/lock.svg?react"; @@ -86,8 +87,9 @@ function Sidebar() { const location = useLocation(); const dispatch = useDispatch(); const authState = useSelector((state) => state.auth); + const { sidebar } = useSelector((state) => state.ui); + let collapsed = sidebar.collapsed; const [open, setOpen] = useState({ Dashboard: false, Account: false }); - const [collapsed, setCollapsed] = useState(false); const [anchorEl, setAnchorEl] = useState(null); const [popup, setPopup] = useState(); @@ -157,7 +159,7 @@ function Sidebar() { borderColor: theme.palette.otherColors.graishWhite, }, }} - onClick={() => setCollapsed(!collapsed)} + onClick={() => dispatch(toggleSidebar())} > {collapsed ? : } diff --git a/Client/src/Features/UI/uiSlice.js b/Client/src/Features/UI/uiSlice.js index bbee3082b..17523977a 100644 --- a/Client/src/Features/UI/uiSlice.js +++ b/Client/src/Features/UI/uiSlice.js @@ -13,10 +13,14 @@ const uiSlice = createSlice({ name: "ui", initialState, reducers: { - setRowsPerPage: (state, action) => {}, - setCollapsed: (state, action) => {}, + setTablePreferences: (state, action) => { + state.table = { ...action }; + }, + toggleSidebar: (state) => { + state.sidebar.collapsed = !state.sidebar.collapsed; + }, }, }); export default uiSlice.reducer; -export const { setRowsPerPage, setCollapsed } = uiSlice.actions; +export const { setTablePreferences, toggleSidebar } = uiSlice.actions;