import express from "express";
import { Request } from "$controllers/index.js";
import {
  checkPermission,
  ensureSepahVerified,
  ensureTadbirVerified,
  requireSejamVerified,
} from "$middlewares/index.js";

const router = express.Router();

router.get("/", checkPermission("requests:view"), Request.ALL);
router.post(
  "/redemption-investor",
  requireSejamVerified,
  ensureSepahVerified,
  ensureTadbirVerified,
  Request.CREATE_REDEMPTION,
);
router.get(
  "/:id/history",
  checkPermission("requestHistories:view"),
  Request.HISTORY,
);
router.post(
  "/:id/reconcile-tadbir",
  checkPermission("requestHistories:view"),
  Request.RECONCILE_TADBIR_SINGLE,
);
router.post(
  "/:id/retry-tadbir-issuance",
  checkPermission("requestHistories:view"),
  Request.RETRY_TADBIR_ISSUANCE_SINGLE,
);
router.get("/:id", checkPermission("requests:view"), Request.SINGLE);
router.post(
  "/",
  checkPermission("requests:create"),
  Request.CREATE,
);
router.put("/:id", checkPermission("requests:update"), Request.UPDATE);
router.delete("/:id", checkPermission("requests:delete"), Request.DELETE);

export default router;
