import type { Metadata } from "next"; import Link from "next/link"; import { CaseAbout, caseKinds, CaseStatus } from "@/components/cases"; import { PageHeader } from "@/components/status"; import { DateTime } from "@/components/time"; import { Button, buttonVariants } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { api, unwrap } from "@/lib/api"; import { ConsoleNav, requireConsole } from "../console-nav"; export const metadata: Metadata = { title: "Cases" }; const statuses = ["open", "resolved", "declined"] as const; const kinds = ["report", "rating-review", "removal-request", "catalog-deletion", "appeal"] as const; export default async function CasesPage({ searchParams }: { searchParams: Promise> }) { await requireConsole("/console/cases"); const params = await searchParams; // Open cases unless asked otherwise ("any" for all). const status = params.status === "any" ? undefined : (statuses.find((s) => s === params.status) ?? "open"); const kind = kinds.find((k) => k === params.kind); const mine = params.mine === "1"; const before = typeof params.before === "string" && /^\d+$/.test(params.before) ? Number(params.before) : undefined; const data = unwrap( await api.cases.get({ query: { ...(status ? { status } : {}), ...(kind ? { kind } : {}), ...(mine ? { mine: "1" as const } : {}), ...(before ? { before } : {}), limit: 50, }, }), ); const older = new URLSearchParams({ status: status ?? "any", ...(kind ? { kind } : {}), ...(mine ? { mine: "1" } : {}), ...(data.before ? { before: String(data.before) } : {}), }); return ( <> {data.moderator ? "Reports, reviews, requests and appeals." : "Cases you opened, and those about what you manage."}
Open Resolved Declined Any status Any kind {kinds.map((k) => ( {caseKinds[k]} ))} {data.moderator ? "Everyone's" : "All I can see"} Opened by me
{data.cases.length === 0 ? (

Nothing here.

) : ( Case About Opened by Assigned Status Changed {data.cases.map((c) => ( {caseKinds[c.kind] ?? c.kind} #{c.id} {c.openedBy || "someone"} {c.assignee ?? ""} ))}
)}
{data.before && data.cases.length === 50 && (
Older
)} ); }