import axios from "@/config/axios";
import type {
  SellersResponse,
  WholesaleRequestsResponse,
  WithdrawalRequestsResponse,
} from "../types/Types";

export const getSellers = async (
  page: number = 1
): Promise<SellersResponse> => {
  const { data } = await axios.get(`/admin/sellers?page=${page}`);
  return data;
};

export const toggleSellerStatus = async (sellerId: string) => {
  const { data } = await axios.patch(
    `/admin/sellers/approve-register/${sellerId}`
  );
  return data;
};

export const approveContract = async (sellerId: string) => {
  const { data } = await axios.patch(
    `/admin/sellers/approve-contract/${sellerId}`
  );
  return data;
};

export const getWholesaleRequests = async (
  page: number = 1
): Promise<WholesaleRequestsResponse> => {
  const { data } = await axios.get(
    `/admin/sellers/wholesale-requests?page=${page}`
  );
  return data;
};

export const approveWholesaleRequest = async (id: string) => {
  const { data } = await axios.patch(`/admin/sellers/wholesale-requests/${id}`);
  return data;
};

export const getWithdrawalRequests = async (
  page: number = 1
): Promise<WithdrawalRequestsResponse> => {
  const { data } = await axios.get(
    `/admin/financial/withdrawal/requests?page=${page}`
  );
  return data;
};
