Implement the 030-bulk-import-sources feature that adds a one-click bulk import button to load all bestiary sources at once, with real-time progress feedback in the side panel and a toast notification when the panel is closed, plus completion/failure reporting with auto-dismiss on success and persistent display on partial failure, while also hardening the bestiary normalizer to handle variable stat blocks (spell summons with special AC/HP/CR) and skip malformed monster entries gracefully

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-10 23:29:34 +01:00
parent c323adc343
commit 94d125d9c4
14 changed files with 850 additions and 106 deletions

View File

@@ -1,4 +1,4 @@
import { Search } from "lucide-react";
import { Import, Search } from "lucide-react";
import { type FormEvent, useState } from "react";
import type { SearchResult } from "../hooks/use-bestiary.js";
import { BestiarySearch } from "./bestiary-search.js";
@@ -10,6 +10,8 @@ interface ActionBarProps {
onAddFromBestiary: (result: SearchResult) => void;
bestiarySearch: (query: string) => SearchResult[];
bestiaryLoaded: boolean;
onBulkImport?: () => void;
bulkImportDisabled?: boolean;
}
export function ActionBar({
@@ -17,6 +19,8 @@ export function ActionBar({
onAddFromBestiary,
bestiarySearch,
bestiaryLoaded,
onBulkImport,
bulkImportDisabled,
}: ActionBarProps) {
const [nameInput, setNameInput] = useState("");
const [searchOpen, setSearchOpen] = useState(false);
@@ -124,14 +128,27 @@ export function ActionBar({
Add
</Button>
{bestiaryLoaded && (
<Button
type="button"
size="sm"
variant="ghost"
onClick={() => setSearchOpen(true)}
>
<Search className="h-4 w-4" />
</Button>
<>
<Button
type="button"
size="sm"
variant="ghost"
onClick={() => setSearchOpen(true)}
>
<Search className="h-4 w-4" />
</Button>
{onBulkImport && (
<Button
type="button"
size="sm"
variant="ghost"
onClick={onBulkImport}
disabled={bulkImportDisabled}
>
<Import className="h-4 w-4" />
</Button>
)}
</>
)}
</form>
)}