"use client"; import { useRouter } from "next/navigation"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; type Report = { id: string; targetType: "recipe" | "comment" | "user"; targetId: string; reason: string; createdAt: string; reporterName: string; reporterEmail: string; }; export function ReportsQueue({ reports }: { reports: Report[] }) { const router = useRouter(); async function resolve(id: string, status: "reviewed" | "dismissed") { const res = await fetch(`/api/v1/admin/reports/${id}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ status }), }); if (!res.ok) { toast.error("Failed to update report"); return; } toast.success(status === "reviewed" ? "Marked reviewed" : "Dismissed"); router.refresh(); } if (reports.length === 0) { return

No pending reports.

; } return (
{reports.map((r) => (
{r.targetType} {r.targetId}

{r.reason}

Reported by {r.reporterName} ({r.reporterEmail}) ยท {new Date(r.createdAt).toLocaleString()}

))}
); }