"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; const LOCKED = new Set([ "registered", "name_approved", "name_reserved", "resignation_sent", "appointment_accepted", "cancelled", "Moved to step 2", ]); export default function ApproveButton({ id, name, status }: { id: string; name: string; status: string }) { const router = useRouter(); const [loading, setLoading] = useState(false); if (LOCKED.has(status)) return null; async function handle() { if (!confirm(`Approve "${name}" and move to Step 2?`)) return; setLoading(true); await fetch("/api/register/update-status", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id, status: "Moved to step 2" }), }); router.refresh(); } return ( ); }