import { BarChart3, Bell, BookOpen, ChevronLeft, ChevronRight, CircleAlert, ClipboardList, LayoutDashboard, LogOut, Shield, UserCircle2, Users, Users2, X, } from "lucide-react"; import { type ComponentType, useEffect, useState } from "react"; import { NavLink } from "react-router-dom"; import { cn } from "../../lib/utils"; import { BrandLogo } from "../brand/BrandLogo"; import { getUnreadCount } from "../../api/notifications.api"; type NavItem = { label: string; to: string; icon: ComponentType<{ className?: string }>; }; const navItems: NavItem[] = [ { label: "Dashboard", to: "/dashboard", icon: LayoutDashboard }, { label: "User Management", to: "/users", icon: Users }, { label: "Role Management", to: "/roles", icon: Shield }, { label: "Content Management", to: "/content", icon: BookOpen }, { label: "New Content", to: "/new-content", icon: BookOpen }, { label: "Notifications", to: "/notifications", icon: Bell }, { label: "User Log", to: "/user-log", icon: ClipboardList }, { label: "Issue Reports", to: "/issues", icon: CircleAlert }, { label: "Analytics", to: "/analytics", icon: BarChart3 }, { label: "Team Management", to: "/team", icon: Users2 }, { label: "Profile", to: "/profile", icon: UserCircle2 }, ]; type SidebarProps = { isOpen: boolean; isCollapsed: boolean; onToggleCollapse: () => void; onClose: () => void; }; export function Sidebar({ isOpen, isCollapsed, onToggleCollapse, onClose, }: SidebarProps) { const [unreadCount, setUnreadCount] = useState(0); useEffect(() => { const fetchUnread = async () => { try { const res = await getUnreadCount(); setUnreadCount(res.data.unread); } catch { // silently fail } }; fetchUnread(); window.addEventListener("notifications-updated", fetchUnread); return () => window.removeEventListener("notifications-updated", fetchUnread); }, []); return ( <> {/* Mobile overlay */}