'use client'; import { useState, FormEvent } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; export default function EmailCapture() { const [email, setEmail] = useState(''); const [isValid, setIsValid] = useState(true); const [submitted, setSubmitted] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); const [errorMessage, setErrorMessage] = useState(''); const handleSubmit = async (e: FormEvent) => { e.preventDefault(); if (!email) { setIsValid(false); setErrorMessage('Email is required'); return; } setIsSubmitting(true); setErrorMessage(''); try { const response = await fetch('/api/signup', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ email }), }); const data = await response.json(); if (!response.ok) { setIsValid(false); setErrorMessage(data.error || 'Failed to submit email'); return; } setSubmitted(true); setEmail(''); } catch (error) { setIsValid(false); setErrorMessage('Network error. Please try again.'); console.error('Signup error:', error); } finally { setIsSubmitting(false); } }; return (
{submitted ? (

You're on the list!

Check your email for confirmation. We'll notify you when GridPilot launches.

) : (

Join the Waitlist

Be among the first to experience GridPilot when we launch early access.

{ setEmail(e.target.value); setIsValid(true); setErrorMessage(''); }} placeholder="your@email.com" disabled={isSubmitting} className={`w-full px-6 py-4 rounded-lg bg-iron-gray text-white placeholder-gray-500 border transition-all duration-150 ${ !isValid ? 'border-red-500 focus:ring-2 focus:ring-red-500' : 'border-charcoal-outline focus:border-neon-aqua focus:ring-2 focus:ring-neon-aqua/50' } hover:scale-[1.01] disabled:opacity-50 disabled:cursor-not-allowed`} aria-label="Email address" /> {!isValid && errorMessage && (

{errorMessage}

)}
No spam, ever
Early feature access
Priority support
)}
); }