"use client"; import { useActionState } from "react"; export type FormResult = { ok?: boolean; error?: string } | null; export function AuthForm({ action, submit, fields }: { action: (state: FormResult, fd: FormData) => Promise; submit: string; fields: { name: string; label: string; type: string; autoComplete?: string; help?: string }[]; }) { const [state, formAction, pending] = useActionState(action, null); return
{fields.map((f) =>
{f.help && {f.help}}
)} {state && !state.ok &&

{state.error}

}
; }