From 84a98eb26e24fc790bd6a11f2bb0846b146b8d22 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Tue, 23 Jun 2026 08:47:38 +0000 Subject: [PATCH] Deploy --- .../sections/ReservationSection.tsx | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/components/sections/ReservationSection.tsx diff --git a/src/components/sections/ReservationSection.tsx b/src/components/sections/ReservationSection.tsx new file mode 100644 index 0000000..649d7be --- /dev/null +++ b/src/components/sections/ReservationSection.tsx @@ -0,0 +1,123 @@ +'use client' +import { useState } from 'react' +import { CalendarDays, CircleCheck, Clock, MessageSquare, Phone, User, Users } from 'lucide-react' + +interface BookingForm { + customer_name: string + customer_phone: string + customer_email: string + booking_date: string + booking_time: string + party_size: string + notes: string +} + +export default function ReservationSection() { + const [form, setForm] = useState({ + customer_name: '', customer_phone: '', customer_email: '', + booking_date: '', booking_time: '', party_size: '2', notes: '', + }) + const [submitting, setSubmitting] = useState(false) + const [success, setSuccess] = useState(false) + const [error, setError] = useState(null) + + const update = (k: keyof BookingForm) => (e: React.ChangeEvent) => + setForm(p => ({ ...p, [k]: e.target.value })) + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault() + setSubmitting(true) + setError(null) + try { + const res = await fetch('/api/medusa/store/bookings', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + booking_date: form.booking_date, + booking_time: form.booking_time, + service_name: 'Table Reservation', + customer_name: form.customer_name, + customer_phone: form.customer_phone, + customer_email: form.customer_email || undefined, + notes: [`Party of ${form.party_size}`, form.notes].filter(Boolean).join(' — ') || undefined, + }), + signal: AbortSignal.timeout(15000), + }) + if (!res.ok) { + const body = await res.json().catch(() => ({})) + throw new Error((body as any).message || 'Booking failed') + } + setSuccess(true) + } catch (err: any) { + setError(err?.message || 'Could not submit reservation. Please call us directly.') + } finally { + setSubmitting(false) + } + } + + const inputCls = 'w-full border border-border rounded-lg px-3 py-2.5 text-sm bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary' + + if (success) return ( +
+
+ +

Reservation Received!

+

We will confirm your table via phone or email. See you soon!

+ +
+
+ ) + + return ( +
+
+
+

Reserve a Table

+

Book in advance to secure your spot. We'll confirm within 2 hours.

+
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ +