Replace 'pax' booking mode with 'seat' Consolidate inventory summary to track only seat counts Update database schema and UI for seat-centric capacity
27 lines
840 B
TypeScript
27 lines
840 B
TypeScript
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<{
|
|
totalSeats?: number | string | null
|
|
}>(event)
|
|
|
|
const input = parseBookingCapacityInput(body)
|
|
const summary = await getBookingInventorySummary()
|
|
|
|
assertBadRequest(
|
|
input.totalSeats === null || input.totalSeats >= summary.soldSeats,
|
|
`Total seats cannot be lower than the currently sold count of ${summary.soldSeats} seats`
|
|
)
|
|
|
|
const settings = await updateBookingCapacitySettings(input)
|
|
|
|
return {
|
|
settings
|
|
}
|
|
})
|