import express from "express";

import { Club } from "$controllers/index.js";
import { checkPermission } from "$middlewares/index.js";

const router = express.Router();

router.get("/me", checkPermission("club:view"), Club.ME);
router.get("/history", checkPermission("club:view"), Club.HISTORY);
router.get("/referrals", checkPermission("club:view"), Club.REFERRALS);
router.get("/rewards", checkPermission("club:view"), Club.REWARDS);
router.post(
  "/rewards/:id/redeem",
  checkPermission("club:view"),
  Club.REDEEM_REWARD,
);

router.get(
  "/admin/rewards",
  checkPermission("clubRewards:view"),
  Club.ADMIN_REWARDS,
);
router.get(
  "/admin/ledger",
  checkPermission("clubLedger:view"),
  Club.ADMIN_LEDGER,
);
router.get(
  "/admin/referrals",
  checkPermission("clubReferrals:view"),
  Club.ADMIN_REFERRALS,
);
router.get(
  "/admin/redemptions",
  checkPermission("clubRedemptions:view"),
  Club.ADMIN_REDEMPTIONS,
);
router.post(
  "/admin/rewards",
  checkPermission("clubRewards:create"),
  Club.ADMIN_CREATE_REWARD,
);
router.put(
  "/admin/rewards/:id",
  checkPermission("clubRewards:update"),
  Club.ADMIN_UPDATE_REWARD,
);
router.delete(
  "/admin/rewards/:id",
  checkPermission("clubRewards:delete"),
  Club.ADMIN_DELETE_REWARD,
);
router.post(
  "/admin/adjustments",
  checkPermission("clubAdjustments:create"),
  Club.ADMIN_CREATE_ADJUSTMENT,
);

export default router;
