diff --git a/app/dashboard/layout.tsx b/app/dashboard/layout.tsx index 1d64ff7..ac2d4b3 100644 --- a/app/dashboard/layout.tsx +++ b/app/dashboard/layout.tsx @@ -1,12 +1,15 @@ "use client"; import React from "react"; +import { useDispatch, useSelector } from "react-redux"; import { LayoutWrapper } from "../features/dashboard/layout/layoutWrapper"; import { MainContent } from "../features/dashboard/layout/mainContent"; import SideBar from "../features/dashboard/sidebar/Sidebar"; import Header from "../features/dashboard/header/Header"; import { useTokenExpiration } from "../hooks/useTokenExpiration"; import TokenExpirationInfo from "../components/TokenExpirationInfo"; +import { toggleSidebar } from "../redux/ui/uiSlice"; +import { RootState } from "../redux/types"; const DashboardLayout: React.FC<{ children: React.ReactNode }> = ({ children, @@ -14,9 +17,16 @@ const DashboardLayout: React.FC<{ children: React.ReactNode }> = ({ // Monitor token expiration and auto-logout useTokenExpiration(); + const dispatch = useDispatch(); + const isSidebarOpen = useSelector((state: RootState) => state.ui.sidebarOpen); + + const handleToggleSidebar = () => { + dispatch(toggleSidebar()); + }; + return ( - +
diff --git a/app/features/dashboard/header/Header.tsx b/app/features/dashboard/header/Header.tsx index beccad7..d1d4d61 100644 --- a/app/features/dashboard/header/Header.tsx +++ b/app/features/dashboard/header/Header.tsx @@ -1,23 +1,10 @@ import React from "react"; -import { AppBar, Toolbar, IconButton } from "@mui/material"; -import MenuIcon from "@mui/icons-material/Menu"; +import { AppBar, Toolbar } from "@mui/material"; import Dropdown from "./dropDown/DropDown"; import AccountMenu from "./accountMenu/AccountMenu"; import "./Header.scss"; const Header = () => { - // const [anchorEl, setAnchorEl] = useState(null); - - // // Handle menu open - // const handleMenuClick = (event: React.MouseEvent) => { - // setAnchorEl(event.currentTarget); - // }; - - // // Handle menu close - // const handleMenuClose = () => { - // setAnchorEl(null); - // }; - const handleChange = () => {}; return ( @@ -30,9 +17,6 @@ const Header = () => { >
- - -
diff --git a/app/features/dashboard/layout/mainContent.ts b/app/features/dashboard/layout/mainContent.ts deleted file mode 100644 index 1b21900..0000000 --- a/app/features/dashboard/layout/mainContent.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { styled } from "@mui/system"; - -export const MainContent = styled("div")(({ theme }) => ({ - marginLeft: "240px", - padding: theme.spacing(3), - minHeight: "100vh", - width: "calc(100% - 240px)", -})); diff --git a/app/features/dashboard/layout/mainContent.tsx b/app/features/dashboard/layout/mainContent.tsx new file mode 100644 index 0000000..d318b8f --- /dev/null +++ b/app/features/dashboard/layout/mainContent.tsx @@ -0,0 +1,21 @@ +import React from "react"; +import { useSelector } from "react-redux"; +import { RootState } from "../../redux/types"; + +interface MainContentProps { + children: React.ReactNode; +} + +export const MainContent = ({ children }: MainContentProps) => { + const isSidebarOpen = useSelector((state: RootState) => state.ui.sidebarOpen); + + const style: React.CSSProperties = { + marginLeft: isSidebarOpen ? "240px" : "30px", + padding: "24px", + minHeight: "100vh", + width: isSidebarOpen ? "calc(100% - 240px)" : "calc(100% - 30px)", + transition: "margin-left 0.3s ease-in-out, width 0.3s ease-in-out", + }; + + return
{children}
; +}; diff --git a/app/features/dashboard/sidebar/Sidebar.tsx b/app/features/dashboard/sidebar/Sidebar.tsx index 0eef7e7..15fe8ec 100644 --- a/app/features/dashboard/sidebar/Sidebar.tsx +++ b/app/features/dashboard/sidebar/Sidebar.tsx @@ -7,8 +7,15 @@ import PageLinks from "../../../components/PageLinks/PageLinks"; import "./sideBar.scss"; import KeyboardArrowRightIcon from "@mui/icons-material/KeyboardArrowRight"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; +import ChevronLeftIcon from "@mui/icons-material/ChevronLeft"; +import ChevronRightIcon from "@mui/icons-material/ChevronRight"; -const SideBar = () => { +interface SidebarProps { + isOpen?: boolean; + onClose?: () => void; +} + +const SideBar = ({ isOpen = true, onClose }: SidebarProps) => { const [openMenus, setOpenMenus] = useState>({}); const toggleMenu = (title: string) => { @@ -16,10 +23,13 @@ const SideBar = () => { }; return ( -