import { useQuery } from '@tanstack/react-query';

import { locationQueryKeys } from '../location-query-keys';
import { locationApi, type PostIsFeatureActiveReturn } from '../location-api';

import type { BaseAxiosError } from '../../../../types';

export const usePostIsFeatureActiveQuery = (token: string, enabled: boolean) => {
  return useQuery<PostIsFeatureActiveReturn, BaseAxiosError>({
    queryKey: locationQueryKeys.isFeatureActive(token),
    queryFn: async () => {
      const response = await locationApi.isFeatureActive(token);
      return response.data;
    },
    enabled
  });
};
