"use client"; import { usePathname } from "next/navigation"; import Link from "next/link"; import { SidebarProvider, Sidebar, SidebarContent, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarHeader, SidebarInset, SidebarTrigger, } from "@/components/ui/sidebar"; import { ClipboardList, House, KeyRound, LucideIcon, Server, Upload, } from "lucide-react"; import { ThemeToggle } from "@/components/theme-toggle"; import { DropdownMenuAvatar, DiscordMemberProfile } from "@/components/avatar"; interface NavItem { href: string; label: string; icon: LucideIcon; isActive: (pathname: string) => boolean; disabled?: boolean; } const NAV_GROUPS: { label: string; items: NavItem[] }[] = [ { label: "Workspace", items: [ { href: "/admin", label: "Home", icon: House, isActive: (pathname) => pathname === "/admin", }, { href: "/admin/form", label: "Forms", icon: ClipboardList, isActive: (pathname) => pathname.startsWith("/admin/form"), }, ], }, { label: "Operations", items: [ { href: "/admin/backend", label: "Backend", icon: Server, isActive: (pathname) => pathname.startsWith("/admin/backend"), }, { href: "/admin/upload", label: "Upload", icon: Upload, isActive: (pathname) => pathname.startsWith("/admin/upload"), disabled: true, }, ], }, { label: "Platform access", items: [ { href: "/admin/login", label: "Login", icon: KeyRound, isActive: (pathname) => pathname.startsWith("/admin/login"), }, ], }, ]; export function AdminShell({ children, userName, userImage, profile, healthStatus, }: { children: React.ReactNode; userName?: string; userImage?: string; profile?: DiscordMemberProfile | null; healthStatus?: React.ReactNode; }) { const pathname = usePathname(); if (/^\/admin\/form\/[^/]+/.test(pathname)) { return children; } return (
Admin
{(userName || profile) && ( )}
{healthStatus} {NAV_GROUPS.map((group) => ( {group.label} {group.items.map(({ href, label, icon: Icon, isActive, disabled }) => ( {disabled ? ( {label} ) : ( {label} )} ))} ))}
{children}
); }