import { useState } from "react"; import { cn } from "@/editor/lib/utils"; import { Typography } from "@/editor/theme/Typography"; export type NewsletterCtaProps = { tagline: string; heading: string; subheading: string; buttonLabel: string; endpoint: string; imageUrl: string; layout: "split" | "stacked"; }; export function NewsletterCta({ tagline, heading, subheading, buttonLabel, endpoint, imageUrl, layout, }: NewsletterCtaProps) { const [email, setEmail] = useState(""); const [submitted, setSubmitted] = useState(false); const [submitting, setSubmitting] = useState(false); const submit = async (e: React.FormEvent) => { e.preventDefault(); if (!email) return; setSubmitting(true); try { if (endpoint) { await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email }), }); } setSubmitted(true); } catch { setSubmitted(true); } finally { setSubmitting(false); } }; const Form = (
); if (layout === "split") { return ({tagline}
) : null}Thanks — we'll be in touch.
) : ( Form )}{tagline}
) : null}Thanks — we'll be in touch.
) : ( Form )}