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], []);
}
