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

export const extensionFundAccountResultSummary = (params: ExtensionFundAccountResultSummaryParams) => {
  return resultify(
    axios.post<ExtensionFundAccountResultSummaryResponse>(API_URL_ADDITIONAL_SERVICE.extensionFundAccountResultSummary(), params),
  );
};

export const useExtensionFundAccountResultSummaryMutation = (options?: UseMutationOptions<ExtensionFundAccountResultSummaryResponse, CBDCAxiosError, ExtensionFundAccountResultSummaryParams>) => {
  const mutation = useMutation<ExtensionFundAccountResultSummaryResponse, CBDCAxiosError, ExtensionFundAccountResultSummaryParams>({
    ...options,
    mutationFn: (params: ExtensionFundAccountResultSummaryParams) => extensionFundAccountResultSummary(params),
  });

  return {
    ...mutation,
  };
};
