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

export const extensionAccountHolderAuthList = (params: ExtensionAccountHolderAuthListParams) => {
    return resultify(
        axios.post<ExtensionAccountHolderAuthListResponse>(API_URL_ADDITIONAL_SERVICE.extensionAccountHolderAuthList(), params),
    );
};

export const useExtensionAccountHolderAuthListMutation = (options?: UseMutationOptions<ExtensionAccountHolderAuthListResponse, CBDCAxiosError, ExtensionAccountHolderAuthListParams>) => {
    const mutation = useMutation<ExtensionAccountHolderAuthListResponse, CBDCAxiosError, ExtensionAccountHolderAuthListParams>({
        ...options,
        mutationFn: (params: ExtensionAccountHolderAuthListParams) => extensionAccountHolderAuthList(params),
    });
    return {
        ...mutation,
    };
}