25 lines
817 B
TypeScript
25 lines
817 B
TypeScript
import {
|
|
AdminBookingServiceError,
|
|
updateAdminBookingStatus,
|
|
} from '@/modules/admin-booking/services/admin-booking.service';
|
|
import type { AppContext } from '@/types/hono';
|
|
import type { UpdateAdminBookingStatusInput } from '@repo/api-contract';
|
|
|
|
type BookingIdParams = { id: string };
|
|
|
|
export async function updateAdminBookingStatusHandler(c: AppContext) {
|
|
const { id } = c.req.valid('param' as never) as BookingIdParams;
|
|
const payload = c.req.valid('json' as never) as UpdateAdminBookingStatusInput;
|
|
const user = c.get('user');
|
|
|
|
try {
|
|
const booking = await updateAdminBookingStatus(user.id, id, payload);
|
|
return c.json(booking);
|
|
} catch (error) {
|
|
if (error instanceof AdminBookingServiceError) {
|
|
return c.json({ message: error.message }, error.status);
|
|
}
|
|
throw error;
|
|
}
|
|
}
|