Update src/app/page.tsx
This commit is contained in:
@@ -20,6 +20,8 @@ const stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
|
||||
export default function LandingPage() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [email, setEmail] = useState('');
|
||||
const [smsPhone, setSmsPhone] = useState('');
|
||||
|
||||
const handlePayment = async () => {
|
||||
try {
|
||||
@@ -61,6 +63,37 @@ export default function LandingPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSignup = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
try {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
const response = await fetch('/api/send-sms', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
phone: smsPhone,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to send SMS');
|
||||
}
|
||||
|
||||
setEmail('');
|
||||
setSmsPhone('');
|
||||
// Show success message or redirect as needed
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Signup error occurred');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<ThemeProvider
|
||||
defaultButtonVariant="directional-hover"
|
||||
@@ -318,6 +351,10 @@ export default function LandingPage() {
|
||||
inputPlaceholder="Enter your email address"
|
||||
buttonText="Subscribe Now"
|
||||
termsText="We'll send you weekly recipes and cooking tips. Unsubscribe anytime. Check our Privacy Policy for details."
|
||||
onSubmit={(email) => {
|
||||
// Handle newsletter signup
|
||||
console.log('Newsletter signup:', email);
|
||||
}}
|
||||
ariaLabel="Newsletter signup section"
|
||||
className="py-20 md:py-28"
|
||||
titleClassName="text-3xl md:text-5xl font-semibold"
|
||||
@@ -325,6 +362,48 @@ export default function LandingPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="w-full py-20 md:py-28 flex items-center justify-center bg-background">
|
||||
<div className="w-full max-w-md mx-auto px-6">
|
||||
<div className="text-center mb-8">
|
||||
<h2 className="text-3xl md:text-4xl font-semibold mb-4">Sign Up & Get SMS Notification</h2>
|
||||
<p className="text-lg text-foreground/80 mb-6">Join our community and receive cooking updates via SMS.</p>
|
||||
</div>
|
||||
<form onSubmit={handleSignup} className="bg-card rounded-xl p-8 mb-6 space-y-4">
|
||||
<div>
|
||||
<input
|
||||
type="email"
|
||||
placeholder="Enter your email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
required
|
||||
className="w-full px-4 py-2 bg-secondary-cta text-foreground rounded-full border border-accent/30 focus:outline-none focus:ring-2 focus:ring-primary-cta"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="tel"
|
||||
placeholder="Enter your phone number"
|
||||
value={smsPhone}
|
||||
onChange={(e) => setSmsPhone(e.target.value)}
|
||||
required
|
||||
className="w-full px-4 py-2 bg-secondary-cta text-foreground rounded-full border border-accent/30 focus:outline-none focus:ring-2 focus:ring-primary-cta"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
className="w-full py-3 px-6 bg-primary-cta text-background font-semibold rounded-full hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity"
|
||||
>
|
||||
{loading ? 'Processing...' : 'Sign Up & Send SMS'}
|
||||
</button>
|
||||
{error && (
|
||||
<p className="text-red-500 text-sm mt-4 text-center">{error}</p>
|
||||
)}
|
||||
</form>
|
||||
<p className="text-sm text-foreground/60 text-center">We'll send you a welcome SMS and cooking updates</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="w-full py-20 md:py-28 flex items-center justify-center bg-background">
|
||||
<div className="w-full max-w-md mx-auto px-6">
|
||||
<div className="text-center mb-8">
|
||||
|
||||
Reference in New Issue
Block a user