import { Router } from "express";
import {
  listAdminClientReviews,
  getAdminClientReviewById,
  createAdminClientReview,
  updateAdminClientReview,
  deleteAdminClientReview,
} from "../controllers/clientReviewController.js";
import { requireStaff } from "../middleware/authMiddleware.js";
import {
  validateBody,
  validateParams,
  validateQuery,
} from "../middleware/validateRequest.js";
import { asyncHandler } from "../utils/asyncHandler.js";
import {
  clientReviewListQuerySchema,
  clientReviewIdParamSchema,
  createClientReviewSchema,
  updateClientReviewSchema,
} from "../validators/clientReviewValidators.js";

const router = Router();

router.use(requireStaff);

router.get(
  "/",
  validateQuery(clientReviewListQuerySchema),
  asyncHandler(listAdminClientReviews),
);

router.post(
  "/",
  validateBody(createClientReviewSchema),
  asyncHandler(createAdminClientReview),
);

router.get(
  "/:id",
  validateParams(clientReviewIdParamSchema),
  asyncHandler(getAdminClientReviewById),
);

router.patch(
  "/:id",
  validateParams(clientReviewIdParamSchema),
  validateBody(updateClientReviewSchema),
  asyncHandler(updateAdminClientReview),
);

router.delete(
  "/:id",
  validateParams(clientReviewIdParamSchema),
  asyncHandler(deleteAdminClientReview),
);

export default router;
