import { useLiveQuery } from 'dexie-react-hooks';
import { charactersRepo } from '@/lib/db/repositories';
import type { Character } from '@/lib/schemas';

export function useCharacters(campaignId: string): Character[] {
  return useLiveQuery(() => charactersRepo.listByCampaign(campaignId), [campaignId], []);
}

export function useCharacter(id: string): Character | undefined {
  return useLiveQuery(() => charactersRepo.get(id), [id], undefined);
}
