"use client";
import { useState } from "react";
import Link from "next/link";
import { api } from "./api";
export function FlagList({ flags }: { flags: { key: string; value: any; updatedAt: string }[] }) {
const [list, setList] = useState(flags);
return
{list.map((f) => { const slug = f.key.split(":")[1]; return - {f.value.kind}
{slug}
{f.value.reasons?.join("; ") ?? (f.value.kind === "canonical_moved" ? `canonical now ${f.value.to}` : `page changed (${f.value.title ?? "no title"})`)}
; })}{!list.length && - No flags.
}
;
}
export function ReportList({ reports }: { reports: any[] }) {
const [list, setList] = useState(reports);
const setStatus = async (id: string, status: string) => { await api("/api/admin/reports", { method: "PATCH", body: JSON.stringify({ id, status }) }); setList((l) => l.map((r) => (r.id === id ? { ...r, status } : r))); };
return {list.map((r) => {r.toolSlug}{r.status}{new Date(r.createdAt).toLocaleString("en-CA")}{r.contact ? ` ยท ${r.contact}` : ""}{r.status === "open" && }
{r.message}
)}{!list.length && - No reports.
}
;
}