import { useEffect } from "react"; import { CODEX_ENTRIES } from "../../data/codex.js"; import { useGame } from "../../context/GameContext.js"; interface CodexToastItemProps { entryId: string; onDismiss: (id: string) => void; } const CodexToastItem = ({ entryId, onDismiss }: CodexToastItemProps): React.JSX.Element | null => { const entry = CODEX_ENTRIES.find((e) => e.id === entryId); useEffect(() => { const timer = setTimeout(() => { onDismiss(entryId); }, 4000); return () => { clearTimeout(timer); }; }, [entryId, onDismiss]); if (!entry) return null; return (
{ onDismiss(entryId); }}> 📖
✨ Lore Unlocked! {entry.title}
); }; export const CodexToast = (): React.JSX.Element | null => { const { newCodexEntryIds, dismissCodexEntry } = useGame(); if (newCodexEntryIds.length === 0) return null; return (
{newCodexEntryIds.map((id) => ( ))}
); };