import express from "express";
import {
  couponPayHistory,
  createCoupon,
  editCoupon,
  getOneCoupon,
  listAffiliateCoupon,
  listAllCoupon,
  suspendCoupon,
  usedCoupon,
  validateCoupon,
} from "./CouponController.js";

import {
  isAuthenticatedUser,
  authorizeRoles,
} from "../../../middlewares/auth.js";

const router = express.Router();
router.get(
  "/getall",
  isAuthenticatedUser,
  authorizeRoles("admin", "Employee"),
  listAllCoupon
);
router.patch(
  "/create",
  isAuthenticatedUser,
  authorizeRoles("admin", "Employee"),
  createCoupon
);
router.get(
  "/getaffiliate",
  isAuthenticatedUser,
  authorizeRoles("admin", "Employee"),
  listAffiliateCoupon
);
router.patch(
  "/edit/:id",
  isAuthenticatedUser,
  authorizeRoles("admin", "Employee"),
  editCoupon
);
router.get(
  "/getone/:id",
  isAuthenticatedUser,
  authorizeRoles("admin", "Employee"),
  getOneCoupon
);
router.get("/validcoupon/:coupon", validateCoupon);
router.patch(
  "/suspend",
  isAuthenticatedUser,
  authorizeRoles("admin", "Employee"),
  suspendCoupon
);
router.patch(
  "/paycoupon",
  // isAuthenticatedUser,
  usedCoupon
);
/* url:http://localhost:5000/api/v1/coupon/paycoupon
 json structure to paycoupon , Need Header to be auth
{
    "userId":"random1",
    "orderId":"12s213",
    "coupon_code":"3000MONY"
}*/
router.get(
  "/history/:id",
  isAuthenticatedUser,
  authorizeRoles("admin", "Employee"),
  couponPayHistory
);

export default router;
