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

export const extensionLinkPayWaitDownloadExcel = (params: ExtensionLinkPayWaitDownloadExcelParams) => {
    return resultify(
        axios.post<ExtensionLinkPayWaitDownloadExcelRespone>(API_URL_ADDITIONAL_SERVICE.extensionLinkPaymentHistoryDownloadExcel(), params),
    );
};

export const useExtensionLinkPayWaitDownloadExcelMutation = (options?: UseMutationOptions<ExtensionLinkPayWaitDownloadExcelRespone, CBDCAxiosError, ExtensionLinkPayWaitDownloadExcelParams>) => {
    const mutation = useMutation<ExtensionLinkPayWaitDownloadExcelRespone, CBDCAxiosError, ExtensionLinkPayWaitDownloadExcelParams>({
        ...options,
        mutationFn: (params: ExtensionLinkPayWaitDownloadExcelParams) => extensionLinkPayWaitDownloadExcel(params),
    });

    return {
        ...mutation,
    };
};