import { Router } from "express";
import {
  listAdminBrands,
  getAdminBrandById,
  createAdminBrand,
  updateAdminBrand,
  deleteAdminBrand,
} from "../controllers/brandController.js";
import { requireStaff } from "../middleware/authMiddleware.js";
import {
  validateBody,
  validateParams,
  validateQuery,
} from "../middleware/validateRequest.js";
import { asyncHandler } from "../utils/asyncHandler.js";
import {
  brandListQuerySchema,
  brandIdParamSchema,
  createBrandSchema,
  updateBrandSchema,
} from "../validators/brandValidators.js";

const router = Router();

router.use(requireStaff);

router.get(
  "/",
  validateQuery(brandListQuerySchema),
  asyncHandler(listAdminBrands),
);

router.post(
  "/",
  validateBody(createBrandSchema),
  asyncHandler(createAdminBrand),
);

router.get(
  "/:id",
  validateParams(brandIdParamSchema),
  asyncHandler(getAdminBrandById),
);

router.patch(
  "/:id",
  validateParams(brandIdParamSchema),
  validateBody(updateBrandSchema),
  asyncHandler(updateAdminBrand),
);

router.delete(
  "/:id",
  validateParams(brandIdParamSchema),
  asyncHandler(deleteAdminBrand),
);

export default router;
