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

const AdminPaymentMethodsController = require("../../controllers/admin/paymentMethodController");
const createUploader = require("../../middleware/createUploader");

// List
router.get("/", authenticateAdmin, AdminPaymentMethodsController.getPaymentMethods);

// Single
router.get("/:paymentMethodId", authenticateAdmin, AdminPaymentMethodsController.getPaymentMethodById);

// Create
router.post(
  "/",
  authenticateAdmin,
  createUploader({
    folder: 'deposit-img',
    fieldName: 'logo',
    maxSizeMB: 20,
  }),
  audit("payment_methods.create", "payment_method"),
  AdminPaymentMethodsController.createPaymentMethod
);

// Update (partial)
router.patch(
  "/:paymentMethodId",
  authenticateAdmin,
  createUploader({
    folder: 'deposit-img',
    fieldName: 'logo',
    maxSizeMB: 20,
  }),
  audit("payment_methods.update", "payment_method"),
  AdminPaymentMethodsController.updatePaymentMethod
);

// Delete
router.delete(
  "/:paymentMethodId",
  authenticateAdmin,
  audit("payment_methods.delete", "payment_method"),
  AdminPaymentMethodsController.deletePaymentMethod
);

module.exports = router;

/**
 * Mount in adminS.js under /manage:
 *   const AdminPaymentMethodsRoutes = require("./routes/admin/adminPaymentMethodsRoutes");
 *   router.use("/payment-methods", AdminPaymentMethodsRoutes);
 *
 * This matches your existing /manage router pattern. :contentReference[oaicite:2]{index=2}
 */