From d9fd94c95351236d3b5f2cb401fab7d6db5ed9a8 Mon Sep 17 00:00:00 2001 From: development Date: Tue, 13 Jan 2026 13:49:24 +0000 Subject: [PATCH] Update src/app/page.tsx --- src/app/page.tsx | 99 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 5 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 8d5a1bf..29a5d56 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -12,11 +12,16 @@ import BlogCardTwo from '@/components/sections/blog/BlogCardTwo'; import ContactCenter from '@/components/sections/contact/ContactCenter'; import FooterBaseSocial from '@/components/sections/footer/FooterBaseSocial'; import { Flame, Users, CheckCircle, Heart, Sparkles, Mail, Instagram, Facebook, Youtube, Twitter } from "lucide-react"; +import { loadStripe } from '@stripe/stripe-js'; import { useState } from 'react'; +const stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY || ''); + export default function LandingPage() { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); + const [email, setEmail] = useState(''); + const [smsPhone, setSmsPhone] = useState(''); const handlePayment = async () => { try { @@ -38,11 +43,18 @@ export default function LandingPage() { } const { sessionId } = await response.json(); - - if (sessionId) { - window.open(`https://checkout.stripe.com/pay/${sessionId}`, '_blank'); - } else { - setError('Payment session creation failed'); + const stripe = await stripePromise; + + if (!stripe) { + throw new Error('Stripe failed to load'); + } + + const { error: redirectError } = await stripe.redirectToCheckout({ + sessionId, + }); + + if (redirectError) { + setError(redirectError.message || 'Payment failed'); } } catch (err) { setError(err instanceof Error ? err.message : 'Payment error occurred'); @@ -51,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 ( { + // 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" @@ -315,6 +362,48 @@ export default function LandingPage() { /> +
+
+
+

Sign Up & Get SMS Notification

+

Join our community and receive cooking updates via SMS.

+
+
+
+ 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" + /> +
+
+ 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" + /> +
+ + {error && ( +

{error}

+ )} +
+

We'll send you a welcome SMS and cooking updates

+
+
+