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:
26
server/api/bookings/capacity.patch.ts
Normal file
26
server/api/bookings/capacity.patch.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { requireRole } from '../../utils/auth'
|
||||
import { parseBookingCapacityInput } from '../../utils/bookings'
|
||||
import { getBookingInventorySummary, updateBookingCapacitySettings } from '../../utils/booking-repository'
|
||||
import { assertBadRequest } from '../../utils/http'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await requireRole(event, 'super_admin')
|
||||
|
||||
const body = await readBody<{
|
||||
totalTables?: number | string | null
|
||||
}>(event)
|
||||
|
||||
const input = parseBookingCapacityInput(body)
|
||||
const summary = await getBookingInventorySummary()
|
||||
|
||||
assertBadRequest(
|
||||
input.totalTables === null || (input.totalTables * 10) >= summary.soldCapacitySeats,
|
||||
`Total tables cannot be lower than the currently sold capacity of ${summary.soldTables} tables and ${summary.soldSeats} seats`
|
||||
)
|
||||
|
||||
const settings = await updateBookingCapacitySettings(input)
|
||||
|
||||
return {
|
||||
settings
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user