import axios from 'axios';
import { API_URL_ADDITIONAL_SERVICE } from '@/shared/api/api-url-additional-service';
import { resultify } from '@/shared/lib/resultify';
import { NiceAxiosError } from '@/shared/@types/error';
import {
  ExtensionFaceAuthDetailParams,
  ExtensionFaceAuthDetailResponse
} from '../../model/face-auth/types';
import {
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';
import { getHeaderUserAgent } from '@/shared/constants/url';

export const extensionFaceAuthDetail = (params: ExtensionFaceAuthDetailParams) => {
  let headerOptions = {
    menuId: 65,
    apiType: 'SELECT'
  };
  let options = {
    headers: {
      'X-User-Agent': getHeaderUserAgent(headerOptions)
    }
  };
  return resultify(
    axios.post<ExtensionFaceAuthDetailResponse>(API_URL_ADDITIONAL_SERVICE.extensionFaceAuthDetail(), params, options),
  );
};

export const useExtensionFaceAuthDetailMutation = (options?: UseMutationOptions<ExtensionFaceAuthDetailResponse, NiceAxiosError, ExtensionFaceAuthDetailParams>) => {
  const mutation = useMutation<ExtensionFaceAuthDetailResponse, NiceAxiosError, ExtensionFaceAuthDetailParams>({
    ...options,
    mutationFn: (params: ExtensionFaceAuthDetailParams) => extensionFaceAuthDetail(params),
  });

  return {
    ...mutation,
  };
};
