/** Shared shape for server-action results consumed by useActionState forms. */ export interface ActionState { ok?: boolean; error?: string | null; message?: string | null; fieldErrors?: Record; /** arbitrary data returned to the form (e.g. cooldown seconds, QR data URL) */ data?: Record; } export const idle: ActionState = { ok: false, error: null }; export function fieldErrorsFrom(issues: Array<{ path: PropertyKey[]; message: string }>): Record { const out: Record = {}; for (const i of issues) { const k = String(i.path[0] ?? '_'); if (!out[k]) out[k] = i.message; } return out; }