import type { PublicBooking } from '~~/shared/booking' import { requireAuth } from '../../../utils/auth' import { updateBookingRemark } from '../../../utils/booking-repository' import { parseBookingRemarkInput } from '../../../utils/bookings' import { getRequiredRouteParam, httpError } from '../../../utils/http' export default defineEventHandler(async (event): Promise<{ booking: PublicBooking }> => { const auth = await requireAuth(event) const bookingId = getRequiredRouteParam(event, 'id', 'Booking ID') const body = await readBody<{ remark?: string | null }>(event) const input = parseBookingRemarkInput(body) const booking = await updateBookingRemark({ bookingId, remark: input.remark, personInChargeId: auth.user.role === 'super_admin' ? undefined : auth.user.id }) if (!booking) { httpError(404, 'Booking not found') } return { booking } })