const express = require("express");
const { body } = require("express-validator");
const validation = require("../../../../middlewares/routeValidation");
const isAuth = require("../../../../middlewares/authorization");
const jsonParser = require("../../../../helpers/jsonParser");
const pagination = require("../../../../middlewares/pagination");

const {
  getSellerVouchers,
  createSellerVoucher,
  softDeleteVoucher,
  editSellerVoucher,
} = require("../../../../controllers/seller/voucher");
const { SELLER_VOUCHERS_MODULE } = require("../../../../helpers/common");
const checkPermissionMiddleware = require("../../../../middlewares/permission");

const router = express.Router();

router.use(pagination);
router.get(
  "/",
  isAuth,
  pagination,
  checkPermissionMiddleware(SELLER_VOUCHERS_MODULE, "view"),
  getSellerVouchers
);
router.post(
  "/",
  isAuth,
  checkPermissionMiddleware(SELLER_VOUCHERS_MODULE, "add"),
  createSellerVoucher
);
router.delete(
  "/:voucher_id",
  isAuth,
  checkPermissionMiddleware(SELLER_VOUCHERS_MODULE, "delete"),
  softDeleteVoucher
);
router.patch(
  "/:voucher_id",
  isAuth,
  checkPermissionMiddleware(SELLER_VOUCHERS_MODULE, "edit"),
  editSellerVoucher
);
// router.get("/:product_id", isAuth, getSellerProductById);
// router.post("/", isAuth, jsonParser, createSellerProduct);
// router.patch("/:product_id/:photo_id", isAuth, updateProductPhoto);
// router.put("/:product_id", isAuth, updateSellerProduct);

module.exports = router;
