import { resultify } from "@/shared/lib/resultify";
import { ExtensionLinkPaySeparateDetailParams, ExtensionLinkPaySeparateDetailResponse } from "../../model/link-pay/types";
import axios from "axios";
import { API_URL_ADDITIONAL_SERVICE } from "@/shared/api/api-url-additional-service";
import { useMutation, UseMutationOptions } from "@tanstack/react-query";
import { NiceAxiosError } from "@/shared/@types/error";
import { getHeaderUserAgent } from "@/shared/constants/url";

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

export const useExtensionLinkPaySeparateDetail = (options?: UseMutationOptions<ExtensionLinkPaySeparateDetailResponse,NiceAxiosError, ExtensionLinkPaySeparateDetailParams>) => {
    const mutation = useMutation<ExtensionLinkPaySeparateDetailResponse, NiceAxiosError, ExtensionLinkPaySeparateDetailParams>({
        ...options,
        mutationFn: (params: ExtensionLinkPaySeparateDetailParams) => extensionLinkPaySeparateDetail(params),
    });

    return {
        ...mutation,
    };
};