import { useMutation, useQuery } from "@tanstack/react-query";
import * as api from "../service/PaymentService";
import { PaymentStatusType, RejectPaymentType } from "../types/PaymentTypes";

export const useGetPayments = (page: number, type: PaymentStatusType) => {
  return useQuery({
    queryKey: ["payments", page, type],
    queryFn: () => api.getPayments(page, type),
    enabled: type !== "GATEWAY",
  });
};

export const useApproveTransfer = () => {
  return useMutation({
    mutationFn: (variables: string) => api.approveTransfer(variables),
  });
};

export const useRejectTransfer = () => {
  return useMutation({
    mutationFn: (variables: RejectPaymentType) => api.rejectTransfer(variables),
  });
};

export const useGetGateWayPayment = (page: number) => {
  return useQuery({
    queryKey: ["gateway-payments", page],
    queryFn: () => api.getPaymentGateways(page),
  });
};
