Files
ttrpg_manager/src/features/world/hooks.ts
T
NilsBriggen 7100ea8dd4 Phase 9: homebrew content + packs
- Homebrew entity (monster/spell/item/feat/condition) — Dexie v6, repo, hook,
  cascade-deleted with campaign
- Homebrew editor page: per-kind fields + description, create/edit/delete
- Compendium merges campaign homebrew of the matching kind (HB badge, generic
  HomebrewDetail) with the same cross-links (add monster->combat, spell/item->character)
- Content packs: export/import homebrew as JSON (validated, ids reassigned)
- System extensibility documented via the existing RulesSystem registry seam
- Fix: card editors (homebrew/npc/quest/note) debounce-save the FULL snapshot, not
  partial patches — editing two fields fast no longer drops an edit

New homebrew e2e + cascade test coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 07:54:53 +02:00

23 lines
1.1 KiB
TypeScript

import { useLiveQuery } from 'dexie-react-hooks';
import { notesRepo, npcsRepo, questsRepo, calendarRepo, mapsRepo, homebrewRepo } from '@/lib/db/repositories';
import type { Note, Npc, Quest, Calendar, BattleMap, Homebrew } from '@/lib/schemas';
export function useNotes(campaignId: string): Note[] {
return useLiveQuery(() => notesRepo.listByCampaign(campaignId), [campaignId], []);
}
export function useNpcs(campaignId: string): Npc[] {
return useLiveQuery(() => npcsRepo.listByCampaign(campaignId), [campaignId], []);
}
export function useQuests(campaignId: string): Quest[] {
return useLiveQuery(() => questsRepo.listByCampaign(campaignId), [campaignId], []);
}
export function useCalendar(campaignId: string): Calendar | undefined {
return useLiveQuery(() => calendarRepo.get(campaignId), [campaignId], undefined);
}
export function useMaps(campaignId: string): BattleMap[] {
return useLiveQuery(() => mapsRepo.listByCampaign(campaignId), [campaignId], []);
}
export function useHomebrew(campaignId: string): Homebrew[] {
return useLiveQuery(() => homebrewRepo.listByCampaign(campaignId), [campaignId], []);
}