Cases are one queue for what someone has to decide, each with a thread (internal notes for those deciding), an assignee and a decision. Reports about a product go to the teams of the catalogs hosting it and to moderators, and only the reporter and moderators know who reported. A creator lowering a rating opens a rating review; a catalog's owner asking to delete it opens a deletion request; a catalog's team can ask for a product's removal everywhere; the person an action affected can appeal it once, decided by another moderator (an admin may decide their own, flagged). Resolving carries the case out: the rating is lowered, the product removed, the catalog deleted. Notifications reach people on the website (a bell with the unread count) and their proxies (realtime): moderators' edits to their products, removals and restores, decisions and replies on their cases, membership decisions. Also: moderators can restore a removed product, and a product's creator and moderators can see it when it's adult without an adult account (getting and wearing it still need one). Co-Authored-By: Claude Opus 5.5 <[email protected]>
136 lines
5.4 KiB
TypeScript
136 lines
5.4 KiB
TypeScript
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: "Cases", value: data.todo.cases, note: "open, for you to decide", href: "/console/cases" },
|
|
{ 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 (
|
|
<>
|
|
<PageHeader title="Console">What you manage on T5DE.</PageHeader>
|
|
<ConsoleNav />
|
|
<div className="space-y-6">
|
|
<StatGrid stats={todo.filter((s) => s.value > 0 || data.moderation)} />
|
|
<StatGrid stats={mine.filter((s) => s.value > 0)} />
|
|
{hub.length > 0 && <StatGrid stats={hub} />}
|
|
|
|
{data.moderation && (
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle>Online Now</CardTitle>
|
|
<CardDescription>
|
|
{data.moderation.connections} {data.moderation.connections === 1 ? "connection" : "connections"} when
|
|
the page loaded
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<OnlineList initial={data.moderation.online} moderator />
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
|
|
{settings && (
|
|
<Card id="settings">
|
|
<CardHeader>
|
|
<CardTitle>Registration</CardTitle>
|
|
<CardDescription>
|
|
{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."}
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<ActionForm action={setRegistration}>
|
|
<div className="flex gap-2">
|
|
<NativeSelect name="registration" defaultValue={settings.registration} aria-label="Registration">
|
|
<NativeSelectOption value="open">Open</NativeSelectOption>
|
|
<NativeSelectOption value="closed">Closed</NativeSelectOption>
|
|
</NativeSelect>
|
|
<SubmitButton pendingLabel="Setting…">Set</SubmitButton>
|
|
</div>
|
|
</ActionForm>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle>Recent Changes</CardTitle>
|
|
<CardDescription>
|
|
{data.moderation ? "Across the hub." : "To what you manage, and by you."}{" "}
|
|
<Link href="/console/audit" className="underline-offset-4 hover:underline">
|
|
Full audit log
|
|
</Link>
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<AuditTable entries={data.audit} />
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
function StatGrid({ stats }: { stats: Stat[] }) {
|
|
if (stats.length === 0) return null;
|
|
return (
|
|
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
|
{stats.map((s) => (
|
|
<Card key={s.label}>
|
|
<CardHeader>
|
|
<CardDescription>{s.label}</CardDescription>
|
|
<CardTitle className="text-3xl font-semibold tabular-nums">{s.value}</CardTitle>
|
|
</CardHeader>
|
|
<CardContent className="text-sm text-muted-foreground">
|
|
{s.href ? (
|
|
<Link href={s.href} className="underline-offset-4 hover:underline">
|
|
{s.note}
|
|
</Link>
|
|
) : (
|
|
s.note
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|