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

export const extensionFundAccountTransferList = (params: ExtensionFundAccountTransferListParams) => {
  return resultify(
    axios.post<ExtensionFundAccountTransferListResponse>(API_URL_ADDITIONAL_SERVICE.extensionFundAccountTransferList(), params),
  );
};

export const useExtensionFundAccountTransferListMutation = (options?: UseMutationOptions<ExtensionFundAccountTransferListResponse, CBDCAxiosError, ExtensionFundAccountTransferListParams>) => {
  const mutation = useMutation<ExtensionFundAccountTransferListResponse, CBDCAxiosError, ExtensionFundAccountTransferListParams>({
    ...options,
    mutationFn: (params: ExtensionFundAccountTransferListParams) => extensionFundAccountTransferList(params),
  });

  return {
    ...mutation,
  };
};
