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

import { eventsQueryKeys } from '../events-query-keys';
import { eventsApi, type PostGetCanAddEventReturn } from '../events-api';

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

export const useGetCanAddEventQuery = (token: string, enabled: boolean) => {
  return useQuery<PostGetCanAddEventReturn, BaseAxiosError>({
    queryKey: eventsQueryKeys.canAddEvent(token),
    queryFn: async () => {
      const response = await eventsApi.canAddEvent(token);
      return response.data;
    },
    enabled
  });
};
