44 lines
1.1 KiB
React
44 lines
1.1 KiB
React
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>
|
||
);
|
||
}
|