import { useQuery } from '@tanstack/react-query';
import { fetchSubtaskActivities } from '../api';
import { POLLING } from '../lib/constants.js';

export function useSubtaskActivities(taskId: number | null, enabled: boolean) {
  return useQuery({
    queryKey: ['subtaskActivities', taskId],
    queryFn: () => fetchSubtaskActivities(taskId!),
    refetchInterval: enabled ? POLLING.FAST : false,
    enabled: enabled && taskId !== null,
  });
}
