"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import type { WaitingProposal } from "@/lib/articles/verdicts"; // A FACT-CHECK'S PROPOSED VERDICTS (release 29 M8), on the article's tab: each // unruled claim a model proposed a verdict for, with the model's reason, the // model and its prompt version — and Approve (the claim's verdict is set, by // the editor's verdict-review through the registry) or Reject (the claim // stays unruled), each with an optional note. Proposed verdicts are plain // text: a verdict's colour is a ruling's, and these are not rulings yet. The // review sends the verdict and `at` shown (a compare-and-set: a proposal that // changed since is refused, and the refusal shown). Stale proposals are // counted, an unreadable sidecar said. export default function VerdictProposals({ article, waiting, stale = 0, error, }: { article: string; waiting: WaitingProposal[]; // Proposals on claims changed since they were made: not shown, not reviewable. stale?: number; // The sidecar did not read: nothing in it is shown until it is repaired. error?: string; }) { const router = useRouter(); const [left, setLeft] = useState(waiting); const [notes, setNotes] = useState>({}); const [busy, setBusy] = useState(null); const [status, setStatus] = useState<{ ok: boolean; text: string } | null>(null); async function review(p: WaitingProposal, decision: "approve" | "reject") { setBusy(p.claim); setStatus(null); try { const note = notes[p.claim]?.trim(); // The proposal shown: the review is refused (409) if it changed since. const r = await fetch("/api/articles/verdicts", { method: "POST", body: JSON.stringify({ article, claim: p.claim, decision, verdict: p.verdict, at: p.at, ...(note ? { note } : {}) }), }); const body = await r.json(); if (!r.ok) throw new Error(body.error ?? `HTTP ${r.status}`); setLeft((xs) => xs.filter((x) => x.claim !== p.claim)); setStatus({ ok: true, text: decision === "approve" ? `Approved: ${p.claim} is ${p.verdict}.` : `Rejected: ${p.claim} stays unruled.` }); router.refresh(); } catch (e) { setStatus({ ok: false, text: (e as Error).message }); } finally { setBusy(null); } } if (!left.length && !status && !error && !stale) return null; return (
verdict proposals · {left.length} waiting{stale ? ` · ${stale} stale (the claim changed since)` : ""}
{error && (

verdicts.proposed.json does not read: {error}

)} {status && (

{status.text}

)}
    {left.map((p) => (
  • {p.claim} {p.section && {p.section}}

    {p.text}

    {p.verdict} {" "} — {p.reason}

    {p.model} · prompt v{p.promptVersion}
    setNotes({ ...notes, [p.claim]: e.target.value })} />
  • ))}
); }