'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[] = [ { label: 'Access Control', icon: Shield, children: [ { href: '/admin/access-control/users', label: 'Users' }, { href: '/admin/access-control/roles', label: 'Roles' }, { href: '/admin/access-control/organizations', label: 'Organizations' }, ], }, { label: 'Document Control', icon: FileStack, children: [ { href: '/admin/doc-control/projects', label: 'Projects' }, { href: '/admin/doc-control/contracts', label: 'Contracts' }, { href: '/admin/doc-control/numbering', label: 'Numbering' }, { href: '/admin/doc-control/reference', label: 'Reference Data' }, { href: '/admin/doc-control/workflows', label: 'Workflows' }, ], }, { label: 'Drawing Master', icon: FileStack, // Or another icon children: [ { href: '/admin/doc-control/drawings/contract/volumes', label: 'Contract: Volumes' }, { href: '/admin/doc-control/drawings/contract/categories', label: 'Contract: Categories' }, { href: '/admin/doc-control/drawings/contract/sub-categories', label: 'Contract: Sub-categories' }, { href: '/admin/doc-control/drawings/shop/main-categories', label: 'Shop: Main Categories' }, { href: '/admin/doc-control/drawings/shop/sub-categories', label: 'Shop: Sub-categories' }, ], }, { label: 'Monitoring', icon: Activity, children: [ { href: '/admin/monitoring/audit-logs', label: 'Audit Logs' }, { href: '/admin/monitoring/system-logs/numbering', label: 'System Logs' }, { href: '/admin/monitoring/sessions', label: 'Active Sessions' }, ], }, { 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 ( ); }