export function EnhanceEmailForm() {
const [state, formAction, isPending] = useActionState(...);
return (
<div className="max-w-4xl mx-auto p-6 space-y-8">
<h1 className="text-3xl text-center font-bold text-gray-900 mb-2">
Email Enhancer
</h1>
<form action={formAction} className="space-y-6">
<div>
<textarea
aria-label="Email content"
name="content"
rows={8}
className={`w-full px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${
state.errors ? "border-red-500" : "border-gray-300"
}`}
placeholder="Enter your draft email content here..."
disabled={isPending}
defaultValue={state.content ?? ""}
/>
{state.errors && (
<p className="mt-1 text-sm text-red-600">
{state.errors.join(". ")}
</p>
)}
</div>
<button
type="submit"
disabled={isPending}
className="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
>
{isPending ? "Enhancing ..." : "Enhance Email"}
</button>
</form>
</div>
);
}