import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { CaseAbout, caseKinds, CaseStatus, resolveLabel } from "@/components/cases"; import { ActionForm, SubmitButton } from "@/components/forms"; import { PageHeader, Tag } from "@/components/status"; import { DateTime } from "@/components/time"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { api, unwrap } from "@/lib/api"; import { ConsoleNav, requireConsole } from "../../console-nav"; import { addNote, assign, decide } from "../actions"; export const metadata: Metadata = { title: "Case" }; /** What each kind of case asks. */ const asks: Record = { report: "Someone reported this.", "rating-review": "Its creator asks to lower its rating from adult to general.", "removal-request": "A catalog hosting it asks for it to be removed everywhere.", "catalog-deletion": "Its owner asks for it to be deleted.", appeal: "The person it affected asks for this action to be undone.", }; export default async function CasePage({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; if (!/^\d{1,9}$/.test(id)) notFound(); const { me } = await requireConsole(`/console/cases/${id}`); const answer = await api.cases({ id: Number(id) }).get(); if (answer.error) notFound(); const { case: c, notes, canDecide, canAssign } = unwrap(answer); const appealed = c.kind === "appeal" ? (c.data as { action?: string; detail?: Record }) : undefined; return ( <> opened by {c.openedBy || "someone"} {c.assignee && assigned to {c.assignee}}
About {asks[c.kind]}

{appealed && (

Action appealed: {appealed.action} {appealed.detail && Object.keys(appealed.detail).length > 0 && ( {" "} ({Object.entries(appealed.detail) .map(([k, v]) => `${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`) .join(", ")} ) )}

)} {c.reason &&

{c.reason}

} {c.status !== "open" && (

{c.status === "resolved" ? "Resolved" : "Declined"} by {c.decidedBy || "a moderator"}{" "} {c.decidedAt && ( )}

{c.resolution &&

{c.resolution}

}
)}
{canDecide && ( Decide {c.kind === "report" || c.kind === "appeal" ? "Resolving records the decision; take any action where it's done (removed products are restored from Console › Products, edits undone from the product's history)." : `Resolving does it: ${resolveLabel[c.kind]?.toLowerCase()}.`}{" "} {c.openedBy ? `${c.openedBy} is told, with what you write.` : ""}