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 { 
  ExtensionArsDownloadExcelParams,
  ExtensionArsDownloadExcelResponse
} from '../../model/ars/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionArsDownloadExcel = (params: ExtensionArsDownloadExcelParams) => {
  return resultify(
    axios.post<ExtensionArsDownloadExcelResponse>(API_URL_ADDITIONAL_SERVICE.extensionArsDownloadExcel(), params),
  );
};

export const useExtensionArsDownloadExcelMutation = (options?: UseMutationOptions<ExtensionArsDownloadExcelResponse, CBDCAxiosError, ExtensionArsDownloadExcelParams>) => {
  const mutation = useMutation<ExtensionArsDownloadExcelResponse, CBDCAxiosError, ExtensionArsDownloadExcelParams>({
    ...options,
    mutationFn: (params: ExtensionArsDownloadExcelParams) => extensionArsDownloadExcel(params),
  });

  return {
    ...mutation,
  };
};
