import axios from 'axios';
import { API_URL_ADDITIONAL_SERVICE } from '@/shared/api/api-url-additional-service';
import { resultify } from '@/shared/lib/resultify';
import { NiceAxiosError } from '@/shared/@types/error';
import {
  ExtensionFundAccountTransferRegistParams,
  ExtensionFundAccountTransferRegistResponse
} from '../../model/fund-account/types';
import {
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';
import { getHeaderUserAgent } from '@/shared/constants/url';

export const extensionFundAccountTransferRegist = (params: ExtensionFundAccountTransferRegistParams) => {
  let headerOptions = {
    menuId: 55,
    apiType: 'INSERT'
  };
  let options = {
    headers: {
      'X-User-Agent': getHeaderUserAgent(headerOptions)
    }
  };
  return resultify(
    axios.post<ExtensionFundAccountTransferRegistResponse>(API_URL_ADDITIONAL_SERVICE.extensionFundAccountTransferRegist(), params, options),
  );
};

export const useExtensionFundAccountTransferRegistMutation = (options?: UseMutationOptions<ExtensionFundAccountTransferRegistResponse, NiceAxiosError, ExtensionFundAccountTransferRegistParams>) => {
  const mutation = useMutation<ExtensionFundAccountTransferRegistResponse, NiceAxiosError, ExtensionFundAccountTransferRegistParams>({
    ...options,
    mutationFn: (params: ExtensionFundAccountTransferRegistParams) => extensionFundAccountTransferRegist(params),
  });

  return {
    ...mutation,
  };
};
