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

export const extensionLinkPayHistoryResend = (params: ExtensionLinkPayHistoryResendParams) => {
    return resultify(
        axios.post<ExtensionLinkPayHistoryResendResponse>(API_URL_ADDITIONAL_SERVICE.extensionLinkPaymentHistoryResend(), params)
    );
};

export const useExtensionLinkPayHistoryResendMutation = (options?: UseMutationOptions<ExtensionLinkPayHistoryResendResponse, CBDCAxiosError, ExtensionLinkPayHistoryResendParams>) => {
    const mutation = useMutation<ExtensionLinkPayHistoryResendResponse, CBDCAxiosError, ExtensionLinkPayHistoryResendParams>({
        ...options,
        mutationFn: (params: ExtensionLinkPayHistoryResendParams) => extensionLinkPayHistoryResend(params),
    });

    return {
        ...mutation,
    };
};