import { Link, useLocation } from "react-router-dom"; import { BarChart, Building2, ClipboardList, FileText, LogOut, Settings, Users2, UsersRound, ChartAreaIcon, } from "lucide-react"; import { useAuth } from "@/shared/context/AuthContext"; interface MenuItem { label: string; href: string; icon: React.ReactNode; roles: string[]; // role keys allowed to see this item } export const AppSidebar = () => { const location = useLocation(); const { user } = useAuth(); const userRoles = user?.roles.map((role) => role.key) || []; const menuItems: MenuItem[] = [ { label: "Dashboard", href: "/dashboard", icon: , roles: ["super_admin"], }, { label: "Dashboard", href: "/user_management-dashboard", icon: , roles: ["admin", "unit_admin"], }, { label: "Organizations", href: "/organizations", icon: , roles: ["super_admin"], }, { label: "Organization Admins", href: "/organization_admins", icon: , roles: ["super_admin"], }, { label: "User Management", href: "/user_management", icon: , roles: ["admin", "unit_admin"], }, { label: "Content Management", href: "/content-management", icon: , roles: ["admin", "unit_admin"], }, { label: "Bulk Upload", href: "/bulk-upload", icon: , roles: ["unit_admin"], }, { label: "Archives", href: "/archives", icon: , roles: ["unit_admin"], }, { label: "Activity Log", href: "/activity_log", icon: , roles: ["super_admin"], }, { label: "Settings", href: "/settings", icon: , roles: ["super_admin"], }, { label: "Sector Reports", href: "/sector-reports", icon: , roles: ["unit_admin", "admin"], }, ]; const filteredMenu = menuItems.filter((item) => item.roles.some((r) => userRoles.includes(r)), ); return (
Smart Office
{filteredMenu.map((item) => ( ))}
} isActive={false} />
); }; interface MenuItemProps { label: string; href: string; icon: React.ReactNode; isActive?: boolean; } const MenuItem = ({ label, href, icon, isActive = false }: MenuItemProps) => { return ( {icon} {label} ); };