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

export const extensionLinkPayWaitListParam = (params: ExtensionLinkPayWaitListParams) => {
  return resultify(
    axios.post<ExtensionLinkPayWaitListResponse>(API_URL_ADDITIONAL_SERVICE.extensionLinkPaymentWaitList(), params),
  );
};

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

  return {
    ...mutation,
  };
};
