Add dedicated subscribe page and seed all JSON defaults on startup
This commit is contained in:
+14
@@ -774,6 +774,20 @@
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.subscribe-card {
|
||||
max-width: 560px;
|
||||
}
|
||||
|
||||
.subscribe-form {
|
||||
margin-top: 1rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.subscribe-form .btn-secondary {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.thanks-countdown {
|
||||
color: #d4b87a !important;
|
||||
letter-spacing: 0.06em;
|
||||
|
||||
+112
@@ -1127,6 +1127,116 @@ function ThankYouPage() {
|
||||
)
|
||||
}
|
||||
|
||||
function SubscribePage() {
|
||||
const navigate = useNavigate()
|
||||
const [name, setName] = useState('')
|
||||
const [email, setEmail] = useState('')
|
||||
const [honey, setHoney] = useState('')
|
||||
const [status, setStatus] = useState<'idle' | 'submitting' | 'error'>('idle')
|
||||
const [errorMsg, setErrorMsg] = useState('')
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault()
|
||||
setStatus('submitting')
|
||||
setErrorMsg('')
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/contact', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
email,
|
||||
messageType: 'general',
|
||||
message: 'Newsletter signup from subscribe page',
|
||||
subscribe: true,
|
||||
_honey: honey,
|
||||
}),
|
||||
})
|
||||
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}))
|
||||
setErrorMsg((data as { message?: string }).message ?? 'Something went wrong. Please try again.')
|
||||
setStatus('error')
|
||||
return
|
||||
}
|
||||
|
||||
navigate('/subscribe/thanks')
|
||||
} catch {
|
||||
setErrorMsg('Could not connect. Please try again later.')
|
||||
setStatus('error')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Subscribe">
|
||||
<div className="thanks-card subscribe-card">
|
||||
<p className="eyebrow">Verse by Verse with Nate</p>
|
||||
<h1>Subscribe for Updates</h1>
|
||||
<p>
|
||||
Get ministry updates and new episode announcements by email.
|
||||
</p>
|
||||
|
||||
<form className="contact-form subscribe-form" onSubmit={handleSubmit} noValidate>
|
||||
<input
|
||||
type="text"
|
||||
className="contact-honeypot"
|
||||
tabIndex={-1}
|
||||
autoComplete="off"
|
||||
aria-hidden="true"
|
||||
value={honey}
|
||||
onChange={e => setHoney(e.target.value)}
|
||||
/>
|
||||
<label>
|
||||
Name
|
||||
<input
|
||||
type="text"
|
||||
name="name"
|
||||
required
|
||||
autoComplete="name"
|
||||
value={name}
|
||||
onChange={e => setName(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Email
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
required
|
||||
autoComplete="email"
|
||||
value={email}
|
||||
onChange={e => setEmail(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
|
||||
{status === 'error' && <p className="contact-error">{errorMsg}</p>}
|
||||
|
||||
<button type="submit" className="btn-primary" disabled={status === 'submitting'}>
|
||||
{status === 'submitting' ? 'Subscribing…' : 'Subscribe'}
|
||||
</button>
|
||||
<Link to="/" className="btn-secondary">Back to Site</Link>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
function SubscribeThankYouPage() {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Subscription confirmed">
|
||||
<div className="thanks-card">
|
||||
<p className="eyebrow">Verse by Verse with Nate</p>
|
||||
<h1>You are subscribed</h1>
|
||||
<p>
|
||||
Thank you for subscribing. You will receive future ministry updates and episode announcements.
|
||||
</p>
|
||||
<Link to="/" className="btn-primary">Back to Site</Link>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
function LegalPage({ title, body }: { title: string; body: string[] }) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label={title}>
|
||||
@@ -1252,6 +1362,8 @@ export default function App() {
|
||||
<Routes>
|
||||
<Route path="/" element={<LandingPage content={content} />} />
|
||||
<Route path="/thanks" element={<ThankYouPage />} />
|
||||
<Route path="/subscribe" element={<SubscribePage />} />
|
||||
<Route path="/subscribe/thanks" element={<SubscribeThankYouPage />} />
|
||||
<Route path="/admin" element={<AdminShell content={content} onSave={setContent} />} />
|
||||
<Route
|
||||
path="/privacy"
|
||||
|
||||
Reference in New Issue
Block a user