import { Loader2 } from "lucide-react"; import { useId, useState } from "react"; import { getAllSourceCodes } from "../adapters/bestiary-index-adapter.js"; import type { BulkImportState } from "../hooks/use-bulk-import.js"; import { Button } from "./ui/button.js"; import { Input } from "./ui/input.js"; const DEFAULT_BASE_URL = "https://raw.githubusercontent.com/5etools-mirror-3/5etools-src/main/data/bestiary/"; interface BulkImportPromptProps { importState: BulkImportState; onStartImport: (baseUrl: string) => void; onDone: () => void; } export function BulkImportPrompt({ importState, onStartImport, onDone, }: Readonly) { const [baseUrl, setBaseUrl] = useState(DEFAULT_BASE_URL); const baseUrlId = useId(); const totalSources = getAllSourceCodes().length; if (importState.status === "complete") { return (
All sources loaded
); } if (importState.status === "partial-failure") { return (
Loaded {importState.completed}/{importState.total} sources ( {importState.failed} failed)
); } if (importState.status === "loading") { const processed = importState.completed + importState.failed; const pct = importState.total > 0 ? Math.round((processed / importState.total) * 100) : 0; return (
Loading sources... {processed}/{importState.total}
); } // idle state const isDisabled = !baseUrl.trim() || importState.status !== "idle"; return (

Import All Sources

Load stat block data for all {totalSources} sources at once.

setBaseUrl(e.target.value)} className="text-xs" />
); }