"use client"; /** * RedTeamRequestButton — POSTs to /api/h/[id]/red-team to enqueue a Schneier * red_team_review job. Shows the job_id + link to /jobs/[id] once submitted. */ import { useState } from "react"; import Link from "next/link"; import { ArrowUpRight } from "lucide-react"; export function RedTeamRequestButton({ hypothesisId, alreadyReviewed, }: { hypothesisId: string; alreadyReviewed: boolean }) { const [pending, setPending] = useState(false); const [jobId, setJobId] = useState(null); const [error, setError] = useState(null); async function requestReview() { setPending(true); setError(null); try { const r = await fetch(`/api/h/${hypothesisId}/red-team`, { method: "POST" }); const d = (await r.json()) as { job_id?: string; error?: string; message?: string }; if (!r.ok || !d.job_id) { setError(d.error || d.message || `HTTP ${r.status}`); return; } setJobId(d.job_id); } catch (e) { setError((e as Error).message); } finally { setPending(false); } } if (jobId) { return ( Schneier em ação — acompanhar ); } return (
{error && ( {error} )}
); }