import { Router } from "express";
import {
  uploadBannerImages,
  uploadBrandImages,
  uploadProductImages,
  uploadProductTypeImages,
  uploadReviewImages,
  uploadShapeImages,
} from "../controllers/uploadController.js";
import { requireStaff } from "../middleware/authMiddleware.js";
import {
  bannerImageUpload,
  brandImageUpload,
  productImageUpload,
  productTypeImageUpload,
  reviewImageUpload,
  shapeImageUpload,
} from "../middleware/uploadMiddleware.js";
import { asyncHandler } from "../utils/asyncHandler.js";

const router = Router();

router.use(requireStaff);

router.post(
  "/product-images",
  productImageUpload.array("images", 8),
  asyncHandler(uploadProductImages),
);

router.post(
  "/shape-images",
  shapeImageUpload.array("images", 4),
  asyncHandler(uploadShapeImages),
);

router.post(
  "/brand-images",
  brandImageUpload.array("images", 4),
  asyncHandler(uploadBrandImages),
);

router.post(
  "/product-type-images",
  productTypeImageUpload.array("images", 4),
  asyncHandler(uploadProductTypeImages),
);

router.post(
  "/review-images",
  reviewImageUpload.array("images", 1),
  asyncHandler(uploadReviewImages),
);

router.post(
  "/banner-images",
  bannerImageUpload.single("image"),
  asyncHandler(uploadBannerImages),
);

export default router;
