"use client"; import { useState } from "react"; import { ThemeColor, TABLE_ROWS, MANTINE_THEMES, SHADCN_THEMES, TREMOR_THEMES } from "./types"; // Admin Panel surface — internal tool for operating the business. // Context: the ops/support team, not end users. // Shows: system health, user moderation, API config — NOT business metrics. type AdminPage = "System" | "Moderation" | "Config"; const SERVERS = [ { name: "api-prod-01", region: "us-east-1", status: "healthy", cpu: 34, mem: 58, uptime: "99.98%" }, { name: "api-prod-02", region: "us-east-1", status: "healthy", cpu: 41, mem: 62, uptime: "99.97%" }, { name: "worker-01", region: "eu-west-2", status: "warning", cpu: 89, mem: 71, uptime: "99.91%" }, { name: "db-primary", region: "us-east-1", status: "healthy", cpu: 22, mem: 44, uptime: "100%" }, ]; const AUDIT_LOG = [ { user: "alice@co.com", action: "Banned user", target: "spammer@evil.com", time: "2m ago" }, { user: "ben@co.com", action: "Promoted to Admin", target: "clara@co.com", time: "14m ago" }, { user: "system", action: "Rate limit hit", target: "api/v1/search", time: "31m ago" }, { user: "david@co.com", action: "Reset password", target: "eve@co.com", time: "1h ago" }, ]; function StatusDot({ status }: { status: string }) { const color = status === "healthy" ? "#22c55e" : status === "warning" ? "#f59e0b" : "#ef4444"; return
; } function MiniBar({ value, color }: { value: number; color: string }) { const bg = value > 80 ? "#ef444430" : "#f3f4f6"; const fill = value > 80 ? "#ef4444" : color; return (
); } // --------------------------------------------------------------------------- // Admin shell — denser than app shell, breadcrumb + secondary nav // --------------------------------------------------------------------------- function AdminShell({ t, page, onNav, children }: { t: ThemeColor; page: AdminPage; onNav: (p: AdminPage) => void; children: React.ReactNode; }) { const NAV: { label: AdminPage; icon: string; badge?: string }[] = [ { label: "System", icon: "◈", badge: "1 warn" }, { label: "Moderation", icon: "◉" }, { label: "Config", icon: "⚙" }, ]; return (
{/* Left nav */}
Acme Admin
Operations
{NAV.map(({ label, icon, badge }) => ( ))}
{/* Main */}
{/* Top bar */}
Admin/ {page}
v2.4.1-prod
A
{children}
); } // --------------------------------------------------------------------------- // System tab — server health, error rate, uptime // --------------------------------------------------------------------------- function SystemView({ t }: { t: ThemeColor }) { return (
{/* Summary row */}
{[ { l: "Uptime", v: "99.96%", good: true }, { l: "Error rate", v: "0.12%", good: true }, { l: "Avg latency", v: "84ms", good: true }, { l: "Alerts", v: "1 active",good: false }, ].map(s => (

{s.l}

{s.v}

))}
{/* Server table */}
Servers ● Live
{SERVERS.map(s => (

{s.name}

{s.region}

CPU 80 ? "#ef4444" : "#374151", width: 24, textAlign: "right" }}>{s.cpu}%
MEM 80 ? "#ef4444" : "#374151", width: 24, textAlign: "right" }}>{s.mem}%
{s.uptime}
))}
{/* Error timeline */}
Error rate — last 24h
{[2,1,3,2,1,1,0,0,1,2,8,3,2,1,0,1,2,1,1,0,1,0,1,2].map((h, i) => (
5 ? "#ef4444" : h > 2 ? "#f59e0b" : t.activeBg, height: `${Math.max(h * 10, 3)}%`, minHeight: 2 }} /> ))}
); } // --------------------------------------------------------------------------- // Moderation tab — user management with admin actions // --------------------------------------------------------------------------- function ModerationView({ t }: { t: ThemeColor }) { return (
{/* User table with actions */}
User management
{TABLE_ROWS.map(r => (
{r.name[0]}

{r.name}

{r.email}

{r.role} {r.status} {/* Admin action buttons */}
))}
{/* Audit log */}
Audit log
{AUDIT_LOG.map((e, i) => (
{e.user} {e.action} {e.target} {e.time}
))}
); } // --------------------------------------------------------------------------- // Config tab — API keys, feature flags, webhooks // --------------------------------------------------------------------------- function ConfigView({ t }: { t: ThemeColor }) { return (
{/* API keys */}
API Keys
{[ { name: "Production", key: "sk_prod_••••••••••••••3d8f", created: "Jan 2, 2026", last: "2m ago" }, { name: "Staging", key: "sk_test_••••••••••••••9a2c", created: "Dec 10, 2025", last: "1d ago" }, ].map(k => (

{k.name}

{k.key}

Created {k.created} Used {k.last}
))}
{/* Feature flags */}
Feature flags
{[ { flag: "new-onboarding", on: true, env: "production" }, { flag: "ai-suggestions", on: true, env: "production" }, { flag: "bulk-export-v2", on: false, env: "staging" }, { flag: "realtime-collab", on: false, env: "dev" }, ].map(f => (

{f.flag}

{f.env}
))}
{/* Webhooks */}
Webhooks
{[ { url: "https://hooks.slack.com/T0123/B456/••••", events: "user.created", status: "active" }, { url: "https://api.pagerduty.com/webhooks/••••", events: "alert.fired", status: "active" }, ].map((w, i) => (
{w.url} {w.events}
))}
); } // --------------------------------------------------------------------------- // Exported scaffold components // --------------------------------------------------------------------------- export function AdminMantine({ themeColor }: { themeColor?: ThemeColor }) { const [page, setPage] = useState("System"); const t = themeColor ?? MANTINE_THEMES[0]; return ( {page === "System" && } {page === "Moderation" && } {page === "Config" && } ); } export function AdminShadcn({ themeColor }: { themeColor?: ThemeColor }) { const [page, setPage] = useState("System"); const t = themeColor ?? SHADCN_THEMES[0]; return ( {page === "System" && } {page === "Moderation" && } {page === "Config" && } ); } export function AdminTremor({ themeColor }: { themeColor?: ThemeColor }) { const [page, setPage] = useState("System"); const t = themeColor ?? TREMOR_THEMES[0]; return ( {page === "System" && } {page === "Moderation" && } {page === "Config" && } ); } export { MANTINE_THEMES, SHADCN_THEMES, TREMOR_THEMES };