import { useQuery } from "@tanstack/react-query";
import { api, type BatchSummary } from "@/lib/api";

/**
 * Lists parsed batches. Batches are only available when a backend is
 * configured — when running in sample-data mode there's no persisted
 * history, so we leave the query disabled.
 */
export function useBatches(limit?: number) {
  return useQuery<BatchSummary[]>({
    queryKey: ["batches", limit ?? null],
    queryFn: () => api.listBatches(limit),
    enabled: api.isConfigured,
  });
}
