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

export const extensionFundAccountResultList = (params: ExtensionFundAccountResultListParams) => {
  return resultify(
    axios.post<ExtensionFundAccountResultListResponse>(API_URL_ADDITIONAL_SERVICE.extensionFundAccountResultList(), params),
  );
};

export const useExtensionFundAccountResultListMutation = (options?: UseMutationOptions<ExtensionFundAccountResultListResponse, CBDCAxiosError, ExtensionFundAccountResultListParams>) => {
  const mutation = useMutation<ExtensionFundAccountResultListResponse, CBDCAxiosError, ExtensionFundAccountResultListParams>({
    ...options,
    mutationFn: (params: ExtensionFundAccountResultListParams) => extensionFundAccountResultList(params),
  });

  return {
    ...mutation,
  };
};
