import { useMutation, useQueryClient } from "@tanstack/react-query";
import { PaymentRepository } from "../repositories/PaymentRepository";

export const useMakePayment = (onSuccessCallBack) => {
  const client = useQueryClient();
  return useMutation({
    mutationFn: (payload) => PaymentRepository.makePayment(payload),
    onSuccess: (_, varibales) => {
      if (onSuccessCallBack) onSuccessCallBack();
    },
    onError: (error) => {
      showToast(
        error.message ||
          error.response.message ||
          "Something went wrong.Please try again later.",
        "error"
      );
    },
  });
};
export const useVerifyPayment = () => {
  const client = useQueryClient();
  return useMutation({
    mutationFn: (payload) => PaymentRepository.verifyPayment(payload),
    onSuccess: (_, varibales) => {
      if (onSuccessCallBack) onSuccessCallBack();
    },
    onError: (error) => {
      showToast(
        error.message ||
          error.response.message ||
          "Something went wrong.Please try again later.",
        "error"
      );
    },
  });
};
