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

export const extensionFundAccountTransferDetail = (params: ExtensionFundAccountTransferDetailParams) => {
  return resultify(
    axios.post<ExtensionFundAccountTransferDetailResponse>(API_URL_ADDITIONAL_SERVICE.extensionFundAccountTransferDetail(), params),
  );
};

export const useExtensionFundAccountTransferDetailMutation = (options?: UseMutationOptions<ExtensionFundAccountTransferDetailResponse, CBDCAxiosError, ExtensionFundAccountTransferDetailParams>) => {
  const mutation = useMutation<ExtensionFundAccountTransferDetailResponse, CBDCAxiosError, ExtensionFundAccountTransferDetailParams>({
    ...options,
    mutationFn: (params: ExtensionFundAccountTransferDetailParams) => extensionFundAccountTransferDetail(params),
  });

  return {
    ...mutation,
  };
};
