diff --git a/prisma/seed.ts b/prisma/seed.ts index d9f2154..1976b00 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,23 +1,24 @@ import { PrismaClient } from '@prisma/client'; +import { seedPropertyInventory } from '@/lib/properties'; const prisma = new PrismaClient(); async function main() { const existing = await prisma.siteSettings.findFirst(); - if (existing) { - return; + if (!existing) { + await prisma.siteSettings.create({ + data: { + businessName: 'Holiday Property Booking', + tagline: 'Curated stays, clear availability, and a direct booking flow.', + contactEmail: 'hello@example.com', + defaultSeoTitle: 'Holiday Property Booking', + defaultSeoDescription: 'Book holiday properties with live availability, clear pricing, and secure checkout.', + }, + }); } - await prisma.siteSettings.create({ - data: { - businessName: 'Holiday Property Booking', - tagline: 'Curated stays, clear availability, and a direct booking flow.', - contactEmail: 'hello@example.com', - defaultSeoTitle: 'Holiday Property Booking', - defaultSeoDescription: 'Book holiday properties with live availability, clear pricing, and secure checkout.', - }, - }); + await seedPropertyInventory(); } main() @@ -28,4 +29,3 @@ main() .finally(async () => { await prisma.$disconnect(); }); - diff --git a/src/app/bookings/new/page.tsx b/src/app/bookings/new/page.tsx index 40409ef..4315a07 100644 --- a/src/app/bookings/new/page.tsx +++ b/src/app/bookings/new/page.tsx @@ -10,6 +10,12 @@ export const metadata: Metadata = { description: 'Start a holiday property booking, check the live quote core, and continue to checkout.', }; +type NewBookingPageProps = { + searchParams?: Promise<{ + propertySlug?: string; + }>; +}; + async function startBooking(formData: FormData) { 'use server'; @@ -32,7 +38,12 @@ async function startBooking(formData: FormData) { redirect(result.checkoutUrl); } -export default function NewBookingPage() { +export default async function NewBookingPage({ searchParams }: NewBookingPageProps) { + const resolvedSearchParams = searchParams ? await searchParams : undefined; + const selectedPropertySlug = resolvedSearchParams?.propertySlug; + const selectedProperty = + bookingCatalog.find((property) => property.slug === selectedPropertySlug) ?? bookingCatalog[0] ?? null; + return ( <>
@@ -48,12 +59,16 @@ export default function NewBookingPage() {