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 {
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';
import { ExtensionLinkPayWaitListParams, ExtensionLinkPayWaitListResponse } from '../../model/link-pay/types';
import { getHeaderUserAgent } from '@/shared/constants/url';

export const extensionLinkPayWaitListParam = (params: ExtensionLinkPayWaitListParams) => {
  let headerOptions = {
    menuId: 54,
    apiType: 'SELECT'
  };
  let options = {
    headers: {
      'X-User-Agent': getHeaderUserAgent(headerOptions)
    }
  };
  return resultify(
    axios.post<ExtensionLinkPayWaitListResponse>(API_URL_ADDITIONAL_SERVICE.extensionLinkPaymentWaitList(), params, options),
  );
};

export const useExtensionLinkPayWaitListMutation = (options?: UseMutationOptions<ExtensionLinkPayWaitListResponse, NiceAxiosError, ExtensionLinkPayWaitListParams>) => {
  const mutation = useMutation<ExtensionLinkPayWaitListResponse, NiceAxiosError, ExtensionLinkPayWaitListParams>({
    ...options,
    mutationFn: (params: ExtensionLinkPayWaitListParams) => extensionLinkPayWaitListParam(params),
  });

  return {
    ...mutation,
  };
};
