import type { DeleteBookingResponse } from '~~/shared/booking' import { requireAuth } from '../../utils/auth' import { getBookingById, softDeleteBooking } from '../../utils/booking-repository' import { getRequiredRouteParam, httpError } from '../../utils/http' export default defineEventHandler(async (event): Promise => { const auth = await requireAuth(event) const bookingId = getRequiredRouteParam(event, 'id', 'Booking ID') const existingBooking = await getBookingById(bookingId, auth.user.role === 'super_admin' ? undefined : { personInChargeId: auth.user.id }) if (!existingBooking) { httpError(404, 'Booking not found') } const booking = await softDeleteBooking({ bookingId, personInChargeId: auth.user.role === 'super_admin' ? undefined : auth.user.id }) if (!booking) { httpError(404, 'Booking not found') } return { booking } })