import { Router } from "express";
import {
  listAdminFrameShapes,
  getAdminFrameShapeById,
  createAdminFrameShape,
  updateAdminFrameShape,
  deleteAdminFrameShape,
} from "../controllers/frameShapeController.js";
import { requireStaff } from "../middleware/authMiddleware.js";
import {
  validateBody,
  validateParams,
  validateQuery,
} from "../middleware/validateRequest.js";
import { asyncHandler } from "../utils/asyncHandler.js";
import {
  frameShapeListQuerySchema,
  frameShapeIdParamSchema,
  createFrameShapeSchema,
  updateFrameShapeSchema,
} from "../validators/frameShapeValidators.js";

const router = Router();

router.use(requireStaff);

router.get(
  "/",
  validateQuery(frameShapeListQuerySchema),
  asyncHandler(listAdminFrameShapes),
);

router.post(
  "/",
  validateBody(createFrameShapeSchema),
  asyncHandler(createAdminFrameShape),
);

router.get(
  "/:id",
  validateParams(frameShapeIdParamSchema),
  asyncHandler(getAdminFrameShapeById),
);

router.patch(
  "/:id",
  validateParams(frameShapeIdParamSchema),
  validateBody(updateFrameShapeSchema),
  asyncHandler(updateAdminFrameShape),
);

router.delete(
  "/:id",
  validateParams(frameShapeIdParamSchema),
  asyncHandler(deleteAdminFrameShape),
);

export default router;
