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

exports.getCopyTraders = asyncHandler(async (req, res) => {
  const data = await adminCopyTradersService.getCopyTraders(req.query);
  ApiResponse.success(res, data);
});

exports.createCopyTrader = asyncHandler(async (req, res) => {
  const trader = await adminCopyTradersService.createCopyTrader(req.body, req.admin?.id);
  ApiResponse.success(res, { trader }, "Copy trader created");
});

exports.updateCopyTrader = asyncHandler(async (req, res) => {
  const { copyTraderId } = req.params;
  const trader = await adminCopyTradersService.updateCopyTrader(copyTraderId, req.body, req.admin?.id);
  ApiResponse.success(res, { trader }, "Copy trader updated");
});

exports.pauseCopyTrader = asyncHandler(async (req, res) => {
  const { copyTraderId } = req.params;
  const trader = await adminCopyTradersService.pauseCopyTrader(copyTraderId, req.admin?.id);
  ApiResponse.success(res, { trader }, "Copy trader paused");
});

exports.resumeCopyTrader = asyncHandler(async (req, res) => {
  const { copyTraderId } = req.params;
  const trader = await adminCopyTradersService.resumeCopyTrader(copyTraderId, req.admin?.id);
  ApiResponse.success(res, { trader }, "Copy trader resumed");
});
