const router = require("express").Router();
const { authenticateAdmin, audit } = require("../../middleware");

const AdminTransactionsController = require("../../controllers/admin/transactionsController");

// LIST
router.get("/", authenticateAdmin, AdminTransactionsController.getTransactions);

// DEPOSITS ONLY
router.get("/deposits", authenticateAdmin, AdminTransactionsController.getDeposits);

// WITHDRAWALS ONLY
router.get("/withdrawals", authenticateAdmin, AdminTransactionsController.getWithdrawals);

// READ ONE
router.get("/:txId", authenticateAdmin, AdminTransactionsController.getTransactionById);

// CREATE (manual/admin)
router.post(
  "/",
  authenticateAdmin,
  audit("transactions.create", "transaction"),
  AdminTransactionsController.createTransaction
);

// UPDATE
router.put(
  "/:txId",
  authenticateAdmin,
  audit("transactions.update", "transaction"),
  AdminTransactionsController.updateTransaction
);

// DELETE (soft delete)
router.delete(
  "/:txId",
  authenticateAdmin,
  audit("transactions.delete", "transaction"),
  AdminTransactionsController.deleteTransaction
);

module.exports = router;
