import { requireAuth } from '@/middlewares/require-auth.middleware';
import { createAdminBookingHandler } from '@/modules/admin-booking/handlers/create-admin-booking.handler';
import { listAdminBookingsHandler } from '@/modules/admin-booking/handlers/list-admin-bookings.handler';
import { updateAdminBookingStatusHandler } from '@/modules/admin-booking/handlers/update-admin-booking-status.handler';
import type { AppEnv } from '@/types/hono';
import { zValidator } from '@hono/zod-validator';
import {
  createAdminBookingSchema,
  listAdminBookingsQuerySchema,
  updateAdminBookingStatusSchema,
} from '@repo/api-contract';
import { Hono } from 'hono';
import { z } from 'zod';

export const adminBookingRoutes = new Hono<AppEnv>();
const complexIdParamsSchema = z.object({ complexId: z.uuid() });
const bookingIdParamsSchema = z.object({ id: z.uuid() });

adminBookingRoutes.use('*', requireAuth);

adminBookingRoutes.get(
  '/complex/:complexId',
  zValidator('param', complexIdParamsSchema),
  zValidator('query', listAdminBookingsQuerySchema),
  listAdminBookingsHandler
);

adminBookingRoutes.post(
  '/complex/:complexId',
  zValidator('param', complexIdParamsSchema),
  zValidator('json', createAdminBookingSchema),
  createAdminBookingHandler
);

adminBookingRoutes.patch(
  '/:id/status',
  zValidator('param', bookingIdParamsSchema),
  zValidator('json', updateAdminBookingStatusSchema),
  updateAdminBookingStatusHandler
);
