From 7f169d392f28388b362a06c7bb59a2b95a74741c Mon Sep 17 00:00:00 2001 From: bender Date: Sat, 7 Mar 2026 18:48:33 +0000 Subject: [PATCH 1/2] Add src/app/api/contact/route.ts --- src/app/api/contact/route.ts | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/app/api/contact/route.ts diff --git a/src/app/api/contact/route.ts b/src/app/api/contact/route.ts new file mode 100644 index 0000000..bdf54dc --- /dev/null +++ b/src/app/api/contact/route.ts @@ -0,0 +1,61 @@ +import { NextRequest, NextResponse } from 'next/server'; + +interface ContactRequest { + email: string; +} + +interface ContactResponse { + success: boolean; + message: string; + email?: string; +} + +export async function POST(request: NextRequest): Promise> { + try { + const body: ContactRequest = await request.json(); + const { email } = body; + + // Validation: email field is required + if (!email) { + return NextResponse.json( + { success: false, message: 'Email is required' }, + { status: 400 } + ); + } + + // Validation: basic email format check + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + if (!emailRegex.test(email)) { + return NextResponse.json( + { success: false, message: 'Please provide a valid email address' }, + { status: 400 } + ); + } + + // TODO: Integrate with actual backend service + // This could be: + // - Email service (SendGrid, Mailgun, AWS SES) + // - Database storage + // - CRM integration + // - Webhook to external service + + // For now, log the contact request + console.log('Contact form submission:', { email, timestamp: new Date().toISOString() }); + + // Simulate successful submission + return NextResponse.json( + { + success: true, + message: 'Thank you for your interest! We will be in touch shortly.', + email + }, + { status: 200 } + ); + } catch (error) { + console.error('Contact form error:', error); + return NextResponse.json( + { success: false, message: 'An error occurred while processing your request. Please try again.' }, + { status: 500 } + ); + } +} From 9e3f5a8a9f64646679addc34f328d5484dcee922 Mon Sep 17 00:00:00 2001 From: bender Date: Sat, 7 Mar 2026 18:48:34 +0000 Subject: [PATCH 2/2] Update src/app/page.tsx --- src/app/page.tsx | 49 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 64f3cce..74411e1 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -12,6 +12,18 @@ import FooterSimple from "@/components/sections/footer/FooterSimple"; import { Award, CheckCircle, DollarSign, Heart, Shield, Zap } from "lucide-react"; export default function LandingPage() { + // Form submission handler with validation + const handleContactSubmit = (email: string) => { + if (!email || !email.includes("@")) { + console.error("Invalid email format"); + alert("Please enter a valid email address"); + return; + } + console.log("Contact form submitted with email:", email); + // In production, this would send to a backend API + alert("Thank you for subscribing! We'll send you plumbing tips soon."); + }; + return (