feat(bookings): add internal remark field to bookings
Add a remark column to the bookings table for management-only notes. Include UI to view and edit remarks directly from the bookings list. Create API endpoint and database queries to support remark updates.
This commit is contained in:
29
server/api/bookings/[id]/remark.patch.ts
Normal file
29
server/api/bookings/[id]/remark.patch.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user