import axios from 'axios';
import { API_URL_ADDITIONAL_SERVICE } from '@/shared/api/api-url-additional-service';
import { resultify } from '@/shared/lib/resultify';
import { CBDCAxiosError } from '@/shared/@types/error';
import { 
  ExtensionFundAccountBalanceParams,
  ExtensionFundAccountBalanceResponse
} from '../../model/fund-account/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionFundAccountBalance = (params: ExtensionFundAccountBalanceParams) => {
  return resultify(
    axios.post<ExtensionFundAccountBalanceResponse>(API_URL_ADDITIONAL_SERVICE.extensionFundAccountBalance(), params),
  );
};

export const useExtensionFundAccountBalanceMutation = (options?: UseMutationOptions<ExtensionFundAccountBalanceResponse, CBDCAxiosError, ExtensionFundAccountBalanceParams>) => {
  const mutation = useMutation<ExtensionFundAccountBalanceResponse, CBDCAxiosError, ExtensionFundAccountBalanceParams>({
    ...options,
    mutationFn: (params: ExtensionFundAccountBalanceParams) => extensionFundAccountBalance(params),
  });

  return {
    ...mutation,
  };
};
