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

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

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

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