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

export const extensionLinkPayHistoryListParam = (params: ExtensionLinkPayHistoryListParams) => {
  return resultify(
    axios.post<ExtensionLinkPayHistoryListResponse>(API_URL_ADDITIONAL_SERVICE.extensionLinkPaymentHistoryList(), params),
  );
};

export const useExtensionLinkPayHistoryListMutation = (options?: UseMutationOptions<ExtensionLinkPayHistoryListResponse, CBDCAxiosError, ExtensionLinkPayHistoryListParams>) => {
  const mutation = useMutation<ExtensionLinkPayHistoryListResponse, CBDCAxiosError, ExtensionLinkPayHistoryListParams>({
    ...options,
    mutationFn: (params: ExtensionLinkPayHistoryListParams) => extensionLinkPayHistoryListParam(params),
  });

  return {
    ...mutation,
  };
};
