import { validate } from '@/lib/http/validate';
import { requireAuth } from '@/middlewares/require-auth.middleware';
import { requireSuperAdmin } from '@/middlewares/require-super-admin.middleware';
import { createSportHandler } from '@/modules/sport/handlers/create-sport.handler';
import { listSportsHandler } from '@/modules/sport/handlers/list-sports.handler';
import { updateSportHandler } from '@/modules/sport/handlers/update-sport.handler';
import type { AppEnv } from '@/types/hono';
import { zValidator } from '@hono/zod-validator';
import { createSportSchema, updateSportSchema } from '@repo/api-contract';
import { Hono } from 'hono';
import { z } from 'zod';
export const sportRoutes = new Hono<AppEnv>();
const sportIdParamsSchema = z.object({ id: z.uuid() });

sportRoutes.use('*', requireAuth);

sportRoutes.get('/', listSportsHandler);
sportRoutes.post('/', requireSuperAdmin, validate.json(createSportSchema), createSportHandler);
sportRoutes.patch(
  '/:id',
  requireSuperAdmin,
  validate.param(sportIdParamsSchema),
  validate.json(updateSportSchema),
  updateSportHandler
);
