import express from "express";
import {
  affiliatePayHistory,
  createAffiliate,
  editAffiliate,
  getOneAffiliate,
  getOneAffiliateForPay,
  listAllAffiliate,
  payAffiliate,
  suspendAffiliate,
} from "./AffiliateController.js";

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

const router = express.Router();

router.post(
  "/create",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  createAffiliate
);
router.get(
  "/getall",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  listAllAffiliate
);
router.get(
  "/getone/:id",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  getOneAffiliate
);
router.patch(
  "/edit/:id",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  editAffiliate
);
router.patch(
  "/suspend",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  suspendAffiliate
);
router.post(
  "/pay/:id",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  payAffiliate
);
router.get(
  "/getpay/:id",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  getOneAffiliateForPay
);
router.get(
  "/history/:id",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  affiliatePayHistory
);

export default router;
