Skip to content

Commit 20d4196

Browse files
committed
update mailing list functionality.
1 parent ab68905 commit 20d4196

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

components/NewsletterSignup.tsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,24 @@ import { useState } from 'react';
44

55
export default function NewsletterSignup() {
66
const [email, setEmail] = useState('');
7+
const [submittedEmail, setSubmittedEmail] = useState('');
78
const [status, setStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle');
89

910
const handleSubmit = async (e: React.FormEvent) => {
1011
e.preventDefault();
1112
setStatus('loading');
1213

13-
// Simulate API call - replace with your actual mailing list service
14-
setTimeout(() => {
15-
console.log('Email submitted:', email);
16-
setStatus('success');
17-
setEmail('');
18-
setTimeout(() => setStatus('idle'), 3000);
19-
}, 1000);
14+
await fetch("https://austrovis-mailinglist.netlify.app/.netlify/functions/send-mail", {
15+
method: "POST",
16+
headers: { "Content-Type": "application/json" },
17+
body: JSON.stringify({ senderEmail: email }),
18+
});
19+
20+
console.log('Email submitted:', email);
21+
// Alert message will be shown by the success status div below
22+
setSubmittedEmail(email);
23+
setStatus('success');
24+
setEmail('');
2025
};
2126

2227
return (
@@ -27,6 +32,22 @@ export default function NewsletterSignup() {
2732
Join our mailing list to receive updates about upcoming workshops and events.
2833
</p>
2934

35+
{status === 'success' && (
36+
<div className="mb-6 p-4 bg-green-500/20 border border-green-500/50 rounded-lg">
37+
<div className="flex items-start gap-3">
38+
<svg className="w-6 h-6 text-green-400 shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
39+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
40+
</svg>
41+
<div className="text-left">
42+
<h3 className="font-semibold text-green-400 mb-1">Subscription Successful!</h3>
43+
<p className="text-sm text-white/90">
44+
Further instructions to finalize your subscription have been sent to <span className="font-medium text-white">{submittedEmail}</span>
45+
</p>
46+
</div>
47+
</div>
48+
</div>
49+
)}
50+
3051
<form onSubmit={handleSubmit} className="flex flex-col sm:flex-row gap-3 max-w-md mx-auto">
3152
<input
3253
type="email"
@@ -46,11 +67,6 @@ export default function NewsletterSignup() {
4667
</button>
4768
</form>
4869

49-
{status === 'success' && (
50-
<p className="mt-4 text-sm text-white/70">
51-
Thanks for subscribing! Check your email for confirmation.
52-
</p>
53-
)}
5470
{status === 'error' && (
5571
<p className="mt-4 text-sm text-red-400">
5672
Something went wrong. Please try again.

0 commit comments

Comments
 (0)