import React, { useState, useEffect } from "react"; import { Outlet, NavLink, useNavigate, useLocation, } from "react-router-dom"; import { Bell, Menu, LogOut, User, Settings, Home, FolderKanban, X, CalendarDays, SettingsIcon, TimerIcon, HelpCircleIcon, } from "lucide-react"; interface User { email: string; password: string; } interface DashboardLayoutProps { user: User | null; setUser: React.Dispatch>; } const DashboardLayout: React.FC = ({ setUser }) => { const [isSidebarOpen, setSidebarOpen] = useState(true); const [isMobile, setIsMobile] = useState(window.innerWidth < 768); const navigate = useNavigate(); const location = useLocation(); useEffect(() => { const handleResize = () => { const mobile = window.innerWidth < 768; setIsMobile(mobile); setSidebarOpen(!mobile); }; handleResize(); window.addEventListener("resize", handleResize); return () => window.removeEventListener("resize", handleResize); }, []); const handleLogout = () => { localStorage.removeItem("user"); setUser(null); navigate("/login"); }; const toggleSidebar = () => setSidebarOpen(!isSidebarOpen); const closeSidebarOnMobile = () => { if (isMobile) setSidebarOpen(false); }; const menuItems = [ { label: "Dashboard", path: "/dashboard", icon: , exact: true }, { label: "Projects", path: "/dashboard/projects", icon: }, { label: "PTO", path: "/dashboard/leave-adjustments", icon: }, { label: "Timesheet", path: "/dashboard/timesheet", icon: }, { label: "Settings", path: "/dashboard/settings", icon: }, { label: "Help & Support", path: "/dashboard/help-support", icon: }, ]; return (
{/* Sidebar */} {/* Mobile overlay */} {isMobile && isSidebarOpen && (
)} {/* Main Content */}
{/* Navbar */} {/* Page Content */}
); }; export default DashboardLayout;