"use client"; import { FormEvent, useState } from "react"; import formSubmitAction from "./formSubmitAction"; import { useToast } from "@repo/ui/shadcn/use-toast"; import { Loader } from "lucide-react"; function EmailInput() { const [email, setEmail] = useState(""); const { toast } = useToast(); const [loading, setLoading] = useState(false); return (
) => { e.preventDefault(); setLoading(true); const value = await formSubmitAction(email, "token" as string); if (value.success) { setEmail(""); toast({ title: "You are now on the waitlist! 🎉", description: "We will notify you when we launch. Check your inbox and spam folder for a surprise! 🎁", }); } else { console.error("email submission failed: ", value.value); toast({ variant: "destructive", title: "Uh oh! Something went wrong.", description: `${value.value}`, }); } setLoading(false); }} className="flex w-full items-center justify-center gap-2" >
setEmail(e.target.value)} />
{email && ( )}
); } export default EmailInput;