"use client"; import { ReactNode, useState } from "react"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useTheme } from "next-themes"; import { LayoutDashboard, ArrowLeftRight, Cable, KeyRound, ShieldCheck, ShieldOff, BarChart2, History, Settings, LogOut, Menu, Sun, Moon, FileJson2, Users, UserCog, } from "lucide-react"; import { Sheet, SheetContent } from "@/components/ui/sheet"; import { Button } from "@/components/ui/button"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Separator } from "@/components/ui/separator"; import { ScrollArea } from "@/components/ui/scroll-area"; import { cn } from "@/lib/utils"; type User = { id: string; name?: string | null; email?: string | null; image?: string | null; role?: string; }; const NAV_ITEMS = [ { href: "/", label: "Overview", icon: LayoutDashboard, adminOnly: false }, { href: "/proxy-hosts", label: "Proxy Hosts", icon: ArrowLeftRight, adminOnly: true }, { href: "/l4-proxy-hosts", label: "L4 Proxy Hosts", icon: Cable, adminOnly: true }, { href: "/access-lists", label: "Access Lists", icon: KeyRound, adminOnly: true }, { href: "/groups", label: "Groups", icon: Users, adminOnly: true }, { href: "/users", label: "Users", icon: UserCog, adminOnly: true }, { href: "/certificates", label: "Certificates", icon: ShieldCheck, adminOnly: true }, { href: "/waf", label: "WAF", icon: ShieldOff, adminOnly: true }, { href: "/analytics", label: "Analytics", icon: BarChart2, adminOnly: true }, { href: "/audit-log", label: "Audit Log", icon: History, adminOnly: true }, { href: "/api-docs", label: "API Docs", icon: FileJson2, adminOnly: true }, { href: "/settings", label: "Settings", icon: Settings, adminOnly: true }, ] as const; function ThemeToggle() { const { resolvedTheme, setTheme } = useTheme(); return ( ); } function NavContent({ pathname, user, onNavigate }: { pathname: string; user: User; onNavigate?: () => void; }) { const router = useRouter(); const isAdmin = user.role === "admin"; const visibleItems = NAV_ITEMS.filter((item) => !item.adminOnly || isAdmin); return (
Caddy Proxy Manager