V1.0.1: Aldenfell campaign seed, content library, party overview

- Seed now resets the database and seeds the Aldenfell campaign from the
  campaign book: admin DM user, default weapons, locations, bestiary,
  pre-built encounters, and DM/shared notes
- Default weapon/spell/monster library, character profile fields,
  locations and dice mode (new migration)
- Party overview page, pagination, info tips, build preview calc
- Remove stale demo-login hint; notes preserve line breaks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 10:24:48 +02:00
co-authored by Claude Opus 5.5
parent 9b29dc8253
commit 94067f1268
34 changed files with 3158 additions and 391 deletions
+88 -2
View File
@@ -2,12 +2,15 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { apiClient } from './client';
import type {
Campaign,
CampaignLibrary,
CampaignMemberSummary,
CharacterDetail,
CharacterSummary,
DiceMode,
Encounter,
EncounterParticipant,
InventoryItem,
Location,
Monster,
Note,
QuickStats,
@@ -154,12 +157,23 @@ function invalidateCharacter(qc: ReturnType<typeof useQueryClient>, characterId:
qc.invalidateQueries({ queryKey: ['character', characterId] });
}
export function usePatchDiceMode(characterId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async (diceMode: DiceMode) =>
(await apiClient.patch<{ diceMode: DiceMode }>(`/characters/${characterId}/build/dice-mode`, { diceMode })).data
.diceMode,
onSuccess: () => invalidateCharacter(qc, characterId),
});
}
export function useBuildRoll(characterId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async () =>
mutationFn: async (body?: { value?: number; abilitySets?: number[][] }) =>
(await apiClient.post<{ buildStage: string; buildState: Record<string, unknown> }>(
`/characters/${characterId}/build/roll`
`/characters/${characterId}/build/roll`,
body
)).data,
onSuccess: () => invalidateCharacter(qc, characterId),
});
@@ -320,6 +334,78 @@ export function useDeleteMonster(campaignId: string) {
});
}
// --------------------------------------------------------------------------
// Default content library — search/browse, "add to campaign"
// --------------------------------------------------------------------------
export function useCampaignLibrary(campaignId: string | undefined) {
return useQuery({
queryKey: ['campaign', campaignId, 'library'],
enabled: Boolean(campaignId),
staleTime: Infinity, // static reference data — never changes under a campaign
queryFn: async () => (await apiClient.get<CampaignLibrary>(`/campaigns/${campaignId}/library`)).data,
});
}
export function useAddWeaponFromLibrary(campaignId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async (key: string) =>
(await apiClient.post<{ weapon: Weapon }>(`/campaigns/${campaignId}/weapons/from-library`, { key })).data
.weapon,
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'weapons'] }),
});
}
export function useAddSpellFromLibrary(campaignId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async (key: string) =>
(await apiClient.post<{ spell: Spell }>(`/campaigns/${campaignId}/spells/from-library`, { key })).data.spell,
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'spells'] }),
});
}
export function useAddMonsterFromLibrary(campaignId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async (key: string) =>
(await apiClient.post<{ monster: Monster }>(`/campaigns/${campaignId}/monsters/from-library`, { key })).data
.monster,
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'monsters'] }),
});
}
// --------------------------------------------------------------------------
// Locations
// --------------------------------------------------------------------------
export function useCampaignLocations(campaignId: string | undefined) {
return useQuery({
queryKey: ['campaign', campaignId, 'locations'],
enabled: Boolean(campaignId),
queryFn: async () =>
(await apiClient.get<{ locations: Location[] }>(`/campaigns/${campaignId}/locations`)).data.locations,
});
}
export function useCreateLocation(campaignId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async (data: { name: string; description?: string | null }) =>
(await apiClient.post<{ location: Location }>(`/campaigns/${campaignId}/locations`, data)).data.location,
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'locations'] }),
});
}
export function useDeleteLocation(campaignId: string) {
const qc = useQueryClient();
return useMutation({
mutationFn: async (locationId: string) => apiClient.delete(`/campaigns/${campaignId}/locations/${locationId}`),
onSuccess: () => qc.invalidateQueries({ queryKey: ['campaign', campaignId, 'locations'] }),
});
}
// --------------------------------------------------------------------------
// Encounters
// --------------------------------------------------------------------------
+95
View File
@@ -36,6 +36,8 @@ export type BuildStage =
| 'CHOOSING_EQUIPMENT'
| 'COMPLETE';
export type DiceMode = 'DIGITAL' | 'PHYSICAL';
export interface User {
id: string;
email: string;
@@ -77,6 +79,16 @@ export interface CharacterSummary {
tempHp: number;
maxHp: number | null;
armorClass: number | null;
currentLocationId: string | null;
currentLocationName: string | null;
}
export interface Location {
id: string;
campaignId: string;
name: string;
description: string | null;
createdAt: string;
}
export interface AbilityDetail {
@@ -178,6 +190,14 @@ export interface CharacterDetail {
tempHp: number;
armorBonus: number;
specialAbilities: string | null;
background: string | null;
appearance: string | null;
// Absent entirely (not null) in the API response for anyone but the
// owning player — a real server-enforced privacy boundary, not a UI hide.
privateNotes?: string | null;
diceMode: DiceMode;
currentLocationId: string | null;
currentLocation: Location | null;
gold: number;
buildStage: BuildStage;
buildState: Record<string, unknown> | null;
@@ -211,6 +231,31 @@ export interface Monster {
export type EncounterStatus = 'PLANNING' | 'ACTIVE' | 'COMPLETE';
export interface CombatWeapon {
characterWeaponId: string;
name: string;
equipped: boolean;
quantity: number;
attackBonus: number;
damageBonus: number;
damageDice: string;
damageType: string;
}
export interface CombatSpell {
characterSpellId: string;
name: string;
level: number;
prepared: boolean;
}
export interface CharacterCombatInfo {
armorClass: number;
weapons: CombatWeapon[];
spells: CombatSpell[];
spellcasting: { ability: Ability; saveDC: number; attackBonus: number } | null;
}
export interface EncounterParticipant {
id: string;
encounterId: string;
@@ -224,6 +269,7 @@ export interface EncounterParticipant {
isMonster: boolean;
character?: { id: string; name: string } | null;
monster?: { id: string; name: string } | null;
characterCombatInfo?: CharacterCombatInfo;
}
export interface Encounter {
@@ -247,6 +293,55 @@ export interface Note {
author?: { displayName: string };
}
export interface LibraryWeapon {
key: string;
name: string;
category: string;
damageDice: string;
damageType: string;
attackAbility: 'STR' | 'DEX' | 'FINESSE';
properties: string[];
rangeNormal: number | null;
rangeLong: number | null;
}
export interface LibrarySpell {
key: string;
name: string;
level: number;
school: string | null;
castingTime: string | null;
range: string | null;
duration: string | null;
description: string | null;
classes: CharacterClass[];
}
export interface LibraryMonster {
key: string;
name: string;
challengeRating: string | null;
ac: number;
maxHp: number;
speed: number;
strScore: number;
dexScore: number;
conScore: number;
intScore: number;
wisScore: number;
chaScore: number;
attackBonus: number;
damageDice: string | null;
specialTrait: string | null;
notes: string | null;
}
export interface CampaignLibrary {
weapons: LibraryWeapon[];
spells: LibrarySpell[];
monsters: LibraryMonster[];
}
export interface QuickStatsWeapon {
characterWeaponId: string;
weaponId: string;