← back to Homesonspec

apps/admin/src/app/corrections/page.tsx

35 lines

import { prisma } from "@homesonspec/database";
import { CreatedChip } from "@homesonspec/shared-ui";

export const dynamic = "force-dynamic";

export default async function CorrectionsPage() {
  const reports = await prisma.correctionReport.findMany({ orderBy: { createdAt: "desc" }, take: 100 });

  return (
    <div>
      <h1 className="text-2xl font-bold">Correction reports</h1>
      <p className="mt-1 text-sm text-neutral-500">Consumer-submitted "report a problem" items.</p>
      <div className="mt-4 space-y-3">
        {reports.map((report) => (
          <div key={report.id} className="rounded-xl border border-neutral-200 bg-white p-4 text-sm shadow-sm">
            <div className="flex items-center justify-between">
              <span className="font-mono text-xs text-neutral-500">
                {report.entityType} · {report.entityId.slice(0, 10)}… {report.field ? `· ${report.field}` : ""}
              </span>
              <CreatedChip date={report.createdAt} />
            </div>
            <p className="mt-2">{report.message}</p>
            {report.reporterEmail && <p className="mt-1 text-xs text-neutral-500">From: {report.reporterEmail}</p>}
            <span className={`mt-2 inline-block rounded-full px-2 py-0.5 text-xs ${
              report.status === "OPEN" ? "bg-amber-100 text-amber-800" : "bg-neutral-100 text-neutral-600"}`}>
              {report.status}
            </span>
          </div>
        ))}
        {reports.length === 0 && <p className="text-neutral-500">No reports.</p>}
      </div>
    </div>
  );
}