feat(bookings): implement booking system and confirmation flow

Add database tables and repository for managing bookings
Create API endpoints for booking submission and capacity management
Update landing page to persist bookings before WhatsApp redirection
This commit is contained in:
2026-04-12 21:43:30 +08:00
parent 07e5d42005
commit 8541c4a2d1
17 changed files with 1585 additions and 92 deletions

View File

@@ -61,6 +61,43 @@ async function initializeDatabase() {
on user_passkeys (user_id)
`
await sql`
create table if not exists bookings (
id text primary key,
confirmation_token text not null unique,
customer_name text not null,
customer_phone text not null,
booking_mode text not null check (booking_mode in ('table', 'pax')),
quantity integer not null check (quantity >= 1),
seat_count integer not null check (seat_count >= 1),
ticket_type text not null check (ticket_type in ('vip', 'supporter')),
unit_price integer not null check (unit_price >= 0),
total_price integer not null check (total_price >= 0),
person_in_charge_id text not null references users(id) on delete restrict,
person_in_charge_name text not null,
person_in_charge_phone_number text not null,
status text not null check (status in ('pending', 'confirmed')) default 'pending',
confirmed_at timestamptz,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
)
`
await sql`
create table if not exists booking_settings (
id text primary key,
total_tables integer,
total_seats integer,
updated_at timestamptz not null default now()
)
`
await sql`
insert into booking_settings (id)
values ('default')
on conflict (id) do nothing
`
const [existingSuperAdmin] = await sql<{ id: string }[]>`
select id
from users