import { useEffect, useMemo, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { fetchEntry } from '../api'; import VideoPlayer from '../components/VideoPlayer'; import { ConversationPanel, GrammarPanel, KeyPhrasePanel, VocabPanel } from '../components/ItemPanels'; import IgMetaBlock from '../components/IgMetaBlock'; import type { EntryDetail } from '../types'; export default function EntryPage() { const { idEncoded } = useParams(); const navigate = useNavigate(); const [entry, setEntry] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const entryId = useMemo(() => { try { return decodeURIComponent(idEncoded || ''); } catch { return idEncoded || ''; } }, [idEncoded]); useEffect(() => { if (!entryId) return; setLoading(true); fetchEntry(entryId) .then((data) => setEntry(data)) .catch(() => setError('Entry not found')) .finally(() => setLoading(false)); }, [entryId]); if (!entryId) { return
No entry id provided.
; } if (loading) return
Loading entry…
; if (error || !entry) return
{error || 'Entry not found.'}
; const quizLink = `/quiz?mode=entry&id=${encodeURIComponent(entry.id)}`; const ig = entry.ig_meta; return (

{entry.title}

{ig && }
); }