import axios from 'axios';
import { API_URL_TRANSACTION } from '@/shared/api/api-url-transaction';
import { resultify } from '@/shared/lib/resultify';
import { CBDCAxiosError } from '@/shared/@types/error';
import { 
  AllTransactionCancelInfoParams,
  AllTransactionCancelInfoResponse
} from '../model/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';


export const allTransactionCancelInfo = (params: AllTransactionCancelInfoParams) => {
  return resultify(
    axios.post<AllTransactionCancelInfoResponse>(API_URL_TRANSACTION.allTransactionCancelInfo(), params),
  );
};

export const useTransactioCancleInfonMutation = (options?: UseMutationOptions<AllTransactionCancelInfoResponse, CBDCAxiosError, AllTransactionCancelInfoParams>) => {
  const mutation = useMutation<AllTransactionCancelInfoResponse, CBDCAxiosError, AllTransactionCancelInfoParams>({
    ...options,
    mutationFn: (params: AllTransactionCancelInfoParams) => allTransactionCancelInfo(params),
  });

  return {
    ...mutation,
  };
};
