WORKFLOW-APP/components/StatusActions.tsx
Dave da504c45a0 wip: registration wizard, address splits, document panel, appointments
Uncommitted work in progress at the point of starting the Kanban
project. Captures:
- Registration wizard refactor + multi-step routing
- structured physical/postal address fields on companies and directors
- appointments flow (sign + verify)
- document type manager + upload/panel for companies and directors
- status actions, approve button, action/dropdown buttons
- step2 review page

tsconfig.tsbuildinfo is now ignored (build artefact).
2026-08-17 18:33:56 +02:00

43 lines
1.2 KiB
TypeScript

"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
const LOCKED_STATUSES = new Set([
"registered", "name_approved", "name_reserved",
"resignation_sent", "appointment_accepted", "cancelled",
"Moved to step 2",
]);
export default function StatusActions({ id, status }: { id: string; status: string }) {
const router = useRouter();
const [loading, setLoading] = useState(false);
if (LOCKED_STATUSES.has(status)) return null;
async function handleApprove() {
if (!confirm("Mark as approved and lock the link?")) return;
setLoading(true);
try {
const res = await fetch("/api/register/update-status", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id, status: "Moved to step 2" }),
});
if (res.ok) router.refresh();
else alert("Failed: " + await res.text());
} finally {
setLoading(false);
}
}
return (
<button
onClick={handleApprove}
disabled={loading}
className="ml-auto px-5 py-2 rounded border-2 border-success text-success text-sm font-bold hover:bg-success/20 transition-colors disabled:opacity-50"
>
{loading ? "Saving…" : "✓ APPROVE"}
</button>
);
}