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 { 
  ExtensionFundAccountResultExcelParams,
  ExtensionFundAccountResultExcelResponse
} from '../../model/fund-account/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionFundAccountResultExcel = (params: ExtensionFundAccountResultExcelParams) => {
  return resultify(
    axios.post<ExtensionFundAccountResultExcelResponse>(API_URL_ADDITIONAL_SERVICE.extensionFundAccountResultExcel(), params),
  );
};

export const useExtensionFundAccountResultExcelMutation = (options?: UseMutationOptions<ExtensionFundAccountResultExcelResponse, CBDCAxiosError, ExtensionFundAccountResultExcelParams>) => {
  const mutation = useMutation<ExtensionFundAccountResultExcelResponse, CBDCAxiosError, ExtensionFundAccountResultExcelParams>({
    ...options,
    mutationFn: (params: ExtensionFundAccountResultExcelParams) => extensionFundAccountResultExcel(params),
  });

  return {
    ...mutation,
  };
};
