const adminDepositsService = require("../../services/admin/adminDepositsService");
const ApiResponse = require("../../utils/apiResponse");
const { asyncHandler } = require("../../middleware/errorHandler");

exports.getDeposits = asyncHandler(async (req, res) => {
  const source = req.depositSource || "funding";
  const data = await adminDepositsService.getDeposits(source, req.query);
  ApiResponse.success(res, data);
});

exports.confirmDeposit = asyncHandler(async (req, res) => {
  const source = req.depositSource || "funding";
  const { depositId } = req.params;
  const data = await adminDepositsService.confirmDeposit(source, depositId, req.admin?.id);
  ApiResponse.success(res, data, "Deposit confirmed");
});

exports.rejectDeposit = asyncHandler(async (req, res) => {
  const source = req.depositSource || "funding";
  const { depositId } = req.params;
  const data = await adminDepositsService.rejectDeposit(source, depositId, req.body, req.admin?.id);
  ApiResponse.success(res, data, "Deposit rejected");
});
