Files
aibook-fun/marketing-site/components/EmailForm.jsx
T

44 lines
1.1 KiB
React
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useState } from "react";
/**
* Pre-launch email capture. Front-end demo only: on submit it shows a success
* state. Wire `postEmail` to the real CRM endpoint (FluentCRM tag `prelaunch`)
* when the backend is ready.
*/
export default function EmailForm({ className = "", cta = "Send it to me" }) {
const [email, setEmail] = useState("");
const [done, setDone] = useState(false);
async function onSubmit(e) {
e.preventDefault();
if (!email) return;
// TODO: await postEmail(email) — POST to CRM, then setDone(true)
setDone(true);
}
if (done) {
return (
<p className="ok-msg" role="status">
✓ You’re on the list — check your inbox for the preview chapter.
</p>
);
}
return (
<form className={className} onSubmit={onSubmit} noValidate>
<input
className="field"
type="email"
required
placeholder="you@work.com"
aria-label="Email address"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<button className="btn btn-primary" type="submit">
{cta}
</button>
</form>
);
}