"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useState } from "react"; import { cn } from "@/lib/utils"; import { Users, Building2, Settings, FileText, Activity, GitGraph, Shield, BookOpen, FileStack, ChevronDown, ChevronRight, } from "lucide-react"; interface MenuItem { href?: string; label: string; icon: React.ComponentType<{ className?: string }>; children?: { href: string; label: string }[]; } const menuItems: MenuItem[] = [ { href: "/admin/users", label: "Users", icon: Users }, { href: "/admin/organizations", label: "Organizations", icon: Building2 }, { href: "/admin/projects", label: "Projects", icon: FileText }, { href: "/admin/contracts", label: "Contracts", icon: FileText }, { href: "/admin/reference", label: "Reference Data", icon: BookOpen }, { label: "Drawing Master Data", icon: FileStack, children: [ { href: "/admin/drawings/contract/volumes", label: "Contract: Volumes" }, { href: "/admin/drawings/contract/categories", label: "Contract: Categories" }, { href: "/admin/drawings/contract/sub-categories", label: "Contract: Sub-categories" }, { href: "/admin/drawings/shop/main-categories", label: "Shop: Main Categories" }, { href: "/admin/drawings/shop/sub-categories", label: "Shop: Sub-categories" }, ] }, { href: "/admin/numbering", label: "Numbering", icon: FileText }, { href: "/admin/workflows", label: "Workflows", icon: GitGraph }, { href: "/admin/security/roles", label: "Security Roles", icon: Shield }, { href: "/admin/security/sessions", label: "Active Sessions", icon: Users }, { href: "/admin/system-logs/numbering", label: "System Logs", icon: Activity }, { href: "/admin/audit-logs", label: "Audit Logs", icon: Activity }, { href: "/admin/settings", label: "Settings", icon: Settings }, ]; export function AdminSidebar() { const pathname = usePathname(); const [expandedMenus, setExpandedMenus] = useState( // Auto-expand if current path matches a child menuItems .filter(item => item.children?.some(child => pathname.startsWith(child.href))) .map(item => item.label) ); const toggleMenu = (label: string) => { setExpandedMenus(prev => prev.includes(label) ? prev.filter(l => l !== label) : [...prev, label] ); }; return ( ); }