import express from "express";

const router = express.Router();

import {
  createKyc,
  createretaildistributor,
  getAllKyc,
  getAllKycApproved,
  getAllKycRejected,
  getAllPrincipalDistributers,
  getKycById,
  saveFCMTokenForSC,
  saveFCMTokenForTM,
  updateKycStatus,
} from "./KycController.js";
import { isAuthenticatedSalesCoOrdinator } from "../../middlewares/SalesCoOrdinatorAuth.js";
import { authorizeRoles, isAuthenticatedUser } from "../../middlewares/auth.js";
import { isAuthenticatedTerritoryManager } from "../../middlewares/TerritoryManagerAuth.js";
// Pd routes
router
  .route("/kyc/update/:id")
  .patch(
    isAuthenticatedUser,
    authorizeRoles("principal-Distributor"),
    updateKycStatus
  );
router
  .route("/kyc/getAll/")
  .get(isAuthenticatedUser, authorizeRoles("principal-Distributor"), getAllKyc);
router
  .route("/kyc/getAllapproved/")
  .get(isAuthenticatedUser, authorizeRoles("admin"), getAllKycApproved);

router
  .route("/kyc/get-single-kyc/:id")
  .get(
    isAuthenticatedUser,
    authorizeRoles("admin", "principal-Distributor"),
    getKycById
  );

// sales coordinator routes && TM ROUTES
router.route("/kyc/create/").post(isAuthenticatedSalesCoOrdinator, createKyc);

router
  .route("/kyc/create-tm/")
  .post(isAuthenticatedTerritoryManager, createKyc);
  router
  .route("/kyc/create-admin/")
  .post(isAuthenticatedUser,authorizeRoles("admin"), createretaildistributor);

router
  .route("/kyc/getAllrejected/")
  .get(isAuthenticatedSalesCoOrdinator, getAllKycRejected);
router
  .route("/kyc/getAllrejected-tm/")
  .get(isAuthenticatedTerritoryManager, getAllKycRejected);
router
  .route("/kyc/get-pd/")
  .get(isAuthenticatedSalesCoOrdinator, getAllPrincipalDistributers);
router
  .route("/kyc/get-pd-tm/")
  .get(isAuthenticatedTerritoryManager, getAllPrincipalDistributers);

router
  .route("/kyc/get-single-kyc-sc/:id")
  .get(isAuthenticatedSalesCoOrdinator, getKycById);
router
  .route("/kyc/get-single-kyc-tm/:id")
  .get(isAuthenticatedTerritoryManager, getKycById);

router
  .route("/kyc/save-fcm-sc/")
  .post(isAuthenticatedSalesCoOrdinator, saveFCMTokenForSC);
router
  .route("/kyc/save-fcm-tm/")
  .post(isAuthenticatedTerritoryManager, saveFCMTokenForTM);
export default router;
