"use client"; import { useState, FormEvent } from "react"; interface WaitlistFormProps { className?: string; onSuccess?: () => void; } export default function WaitlistForm({ className = "", onSuccess }: WaitlistFormProps) { const [email, setEmail] = useState(""); const [name, setName] = useState(""); const [referralSource, setReferralSource] = useState(""); const [isSubmitting, setIsSubmitting] = useState(false); const [error, setError] = useState(null); const [success, setSuccess] = useState(false); const handleSubmit = async (e: FormEvent) => { e.preventDefault(); setIsSubmitting(true); setError(null); try { const res = await fetch("/api/waitlist", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: email.trim(), name: name.trim() || undefined, referral_source: referralSource || undefined, }), }); const data = await res.json(); if (!res.ok) { throw new Error(data.error || "Failed to join waitlist"); } setSuccess(true); setEmail(""); setName(""); setReferralSource(""); onSuccess?.(); } catch (err) { setError(err instanceof Error ? err.message : "Something went wrong"); } finally { setIsSubmitting(false); } }; if (success) { return (

You're on the list!

We'll be in touch soon with early access details.

); } return (
setName(e.target.value)} placeholder="Your name" className="w-full px-4 py-3 rounded-xl border border-[#6b8f71]/30 bg-white text-[#1a1a1a] placeholder-[#888] focus:outline-none focus:ring-2 focus:ring-[#1a4d2e]/50 focus:border-[#1a4d2e] transition-all" />
setEmail(e.target.value)} placeholder="you@farm.com" required className="w-full px-4 py-3 rounded-xl border border-[#6b8f71]/30 bg-white text-[#1a1a1a] placeholder-[#888] focus:outline-none focus:ring-2 focus:ring-[#1a4d2e]/50 focus:border-[#1a4d2e] transition-all" />
{error && (
{error}
)}

We respect your privacy. No spam, ever.

); }