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

export const extensionFundAccountResultDetail = (params: ExtensionFundAccountResultDetailParams) => {
  return resultify(
    axios.post<ExtensionFundAccountResultDetailResponse>(API_URL_ADDITIONAL_SERVICE.extensionFundAccountResultDetail(), params),
  );
};

export const useExtensionFundAccountResultDetailMutation = (options?: UseMutationOptions<ExtensionFundAccountResultDetailResponse, CBDCAxiosError, ExtensionFundAccountResultDetailParams>) => {
  const mutation = useMutation<ExtensionFundAccountResultDetailResponse, CBDCAxiosError, ExtensionFundAccountResultDetailParams>({
    ...options,
    mutationFn: (params: ExtensionFundAccountResultDetailParams) => extensionFundAccountResultDetail(params),
  });

  return {
    ...mutation,
  };
};
