"use client";
import * as React from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import {
Activity,
ArrowLeft,
Building2,
ChevronDown,
CreditCard,
Flag,
FolderKanban,
Globe,
KeyRound,
LayoutDashboard,
ListTree,
Menu,
Server,
ShieldAlert,
Users,
Waypoints,
Wrench,
X,
} from "lucide-react";
import { cn } from "@/lib/utils";
import { LogoMark } from "@/components/ui/logo";
import { ThemeToggle } from "@/components/ui/theme";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
export const ADMIN_NAV = [
{ href: "/admin", label: "Overview", icon: LayoutDashboard, exact: true },
{ href: "/admin/users", label: "Users", icon: Users },
{ href: "/admin/access", label: "Access", icon: KeyRound },
{ href: "/admin/organizations", label: "Organizations", icon: Building2 },
{ href: "/admin/projects", label: "Projects", icon: FolderKanban },
{ href: "/admin/requests", label: "Requests", icon: ListTree },
{ href: "/admin/usage", label: "Usage", icon: Activity },
{ href: "/admin/providers", label: "Providers", icon: Server },
{ href: "/admin/routing", label: "Routing", icon: Waypoints },
{ href: "/admin/domains", label: "Domains", icon: Globe },
{ href: "/admin/billing", label: "Billing", icon: CreditCard },
{ href: "/admin/abuse", label: "Abuse", icon: ShieldAlert },
{ href: "/admin/system", label: "System", icon: Wrench },
{ href: "/admin/flags", label: "Flags", icon: Flag },
] as const;
function AdminNav({ onNavigate, className }: { onNavigate?: () => void; className?: string }) {
const pathname = usePathname();
return (
);
}
export function AdminShell({ children, user }: { children: React.ReactNode; user: { email: string; name: string } }) {
const pathname = usePathname();
// The menu is "open for" a given pathname, so it closes itself on navigation without an effect.
const [openPath, setOpenPath] = React.useState(null);
const open = openPath === pathname;
const setOpen = (v: boolean | ((prev: boolean) => boolean)) => setOpenPath((prev) => ((typeof v === "function" ? v(prev === pathname) : v) ? pathname : null));
const current = ADMIN_NAV.find((i) => ("exact" in i && i.exact ? pathname === i.href : pathname === i.href || pathname.startsWith(i.href + "/")));
return (
Fetcha Admin
Internal
Upstream provider names and costs are visible here. Never share screenshots externally.
{open ? (
) : null}
{children}
);
}