"use client"; import { useState } from "react"; export function NewsletterForm() { const [email, setEmail] = useState(""); const [status, setStatus] = useState<"idle" | "loading" | "done" | "error">( "idle" ); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (!email) return; setStatus("loading"); try { const res = await fetch("/api/newsletter", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email }), }); setStatus(res.ok ? "done" : "error"); } catch { setStatus("error"); } } if (status === "done") { return

You're on the list.

; } return (
setEmail(e.target.value)} placeholder="your@email.com" required disabled={status === "loading"} className="min-w-0 flex-1 rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-xs text-zinc-200 placeholder-zinc-600 focus:border-amber-500/50 focus:outline-none disabled:opacity-50" />
{status === "error" && (

Something went wrong. Try again.

)}
); }