import type { Metadata } from "next"; import Link from "next/link"; import { ActionForm, SubmitButton } from "@/components/forms"; import { OnlineList } from "@/components/online-list"; import { PageHeader } from "@/components/status"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select"; import { api, unwrap } from "@/lib/api"; import { setRegistration } from "./actions"; import { AuditTable } from "./audit-table"; import { ConsoleNav, requireConsole } from "./console-nav"; export const metadata: Metadata = { title: "Console" }; type Stat = { label: string; value: number; note: string; href?: string }; export default async function Console() { const { me, console: data } = await requireConsole("/console"); const settings = me.role === "admin" ? await api.console.settings.get().then(unwrap) : undefined; const todo: Stat[] = [ { label: "Drafts", value: data.todo.drafts, note: "to review and publish", href: "/console/products?status=draft" }, { label: "Member Requests", value: data.todo.memberRequests, note: "waiting in your catalogs", href: "/console/catalogs" }, ]; if (data.moderation) { todo.push( { label: "Catalogs", value: data.todo.pendingCatalogs, note: "waiting for approval", href: "/console/catalogs" }, { label: "Accounts", value: data.todo.waitingPeople, note: "waiting for approval", href: "/console/people?waiting=true" }, ); } const mine: Stat[] = [ { label: "Your Products", value: data.mine.products, note: "you created", href: "/console/products" }, { label: "Your Catalogs", value: data.mine.catalogs, note: "you're on the team of", href: "/console/catalogs" }, { label: "Your Rooms", value: data.mine.rooms, note: "you host", href: "/rooms" }, ]; const hub: Stat[] = data.moderation ? [ { label: "People", value: data.moderation.counts.people, note: "accounts" }, { label: "IMVU Accounts", value: data.moderation.counts.links, note: "linked" }, { label: "Computers", value: data.moderation.counts.computers, note: "signed in" }, ] : []; return ( <> What you manage on T5DE.
s.value > 0 || data.moderation)} /> s.value > 0)} /> {hub.length > 0 && } {data.moderation && ( Online Now {data.moderation.connections} {data.moderation.connections === 1 ? "connection" : "connections"} when the page loaded )} {settings && ( Registration {settings.registration === "closed" ? "Closed: new accounts can sign in, but wait for a moderator's approval." : "Open: new accounts can use the hub at once."}
Open Closed Set
)} Recent Changes {data.moderation ? "Across the hub." : "To what you manage, and by you."}{" "} Full audit log
); } function StatGrid({ stats }: { stats: Stat[] }) { if (stats.length === 0) return null; return (
{stats.map((s) => ( {s.label} {s.value} {s.href ? ( {s.note} ) : ( s.note )} ))}
); }