// Home dashboard + Vocabulary browser. // Onboarding now lives in onboarding.jsx; this file only renders the // dashboard for already-onboarded users. function Home({ state, setRoute, update }) { const stats = window.api.stats(state); const cfg = window.bandConfig.for(state.targetBand); const today = window.api.todayKey(); const todays = window.planEngine.todaysPlan(state); // SRS counts for the "due now" callout const srsCounts = window.srs.counts(state); // Words at the user's currently selected level (small "level progress" tile) const levelWords = window.api.wordsByLevel(state.level); const learnedAtLevel = levelWords.filter(w => window.api.isLearned(state, w.id)).length; const levelProgress = levelWords.length ? Math.min(100, Math.round((learnedAtLevel / levelWords.length) * 100)) : 0; const wordOfDay = useMemo(() => { const all = window.api.allWords(); if (!all.length) return null; const idx = Math.floor(new Date().getTime() / 86400000) % all.length; return all[idx]; }, []); const grammarLessonCount = window.api.grammarLessons().length; const modes = [ { id: 'vocab', label: 'Vocabulary', icon: 'book', color: 'var(--primary)', bg: 'var(--primary-soft)', desc: 'Browse 5,000+ words with Bangla meanings — 1,290+ with full definitions and examples.', count: `${window.api.wordsForBand(state.targetBand).length} words for band ${state.targetBand}` }, { id: 'quiz', label: 'Vocab Quiz', icon: 'zap', color: 'var(--accent)', bg: 'var(--accent-soft)', desc: 'MCQ drills with instant feedback. Pick the Bangla meaning.', count: `${state.quiz.vocabAttempts} attempted · ${stats.accuracy}% accuracy` }, { id: 'grammar', label: 'Grammar', icon: 'target', color: 'var(--sky)', bg: 'var(--sky-soft)', desc: 'Lessons + MCQ drills on tense, articles, prepositions, and corrections.', count: `${grammarLessonCount} lessons available` }, { id: 'writing', label: 'Sentence Writing', icon: 'edit', color: 'var(--success)', bg: 'var(--success-soft)', desc: 'Write sentences from a prompt. AI checks grammar and gives a correction.', count: `${state.sentences.length} sentences reviewed` }, { id: 'mock', label: 'Mock Tests', icon: 'award', color: 'var(--gold)', bg: 'var(--gold-soft)', desc: 'Real IELTS-style sectional and full mock tests with band scoring.', count: 'Reading · Listening · Writing · Speaking' }, ]; return (
Session {state.sessions + 1} · Level {state.level}

Good {getGreeting()}, {state.userName || 'Learner'}.

Targeting Band {state.targetBand}{state.profile?.examType ? ` · ${state.profile.examType[0].toUpperCase() + state.profile.examType.slice(1)}` : ''}. {getMotivation(state)}

Streak
{state.streak.count} day{state.streak.count !== 1 ? 's' : ''}
{state.plan?.examWarning && (
{state.plan.examWarning === 'past' ? 'Your exam date has already passed — update it in Settings to regenerate an accurate plan.' : 'Your study plan was shortened to fit your exam date — your original pace would have run past it.'}
)} {/* Today's plan */} {todays && state.plan && ( )} {/* Stats row */}
{/* Modes grid */}
Practice modes
{modes.map(m => ( ))}
{/* Word of the day */} {wordOfDay && ( <>
Word of the day
{wordOfDay.pos} · Level {wordOfDay.lvl}
{wordOfDay.w}
{wordOfDay.b}
{wordOfDay.ex &&
"{wordOfDay.ex}"
}
)}
); } function TodaysPlan({ plan, state, setRoute, update }) { const { week, day, notStartedYet, finished } = plan; const completion = window.planEngine.dayCompletion(state, day); if (notStartedYet) { return (
Your plan starts {day.dateKey}
You're ahead of schedule.
Want to start anyway? You can take any module without waiting.
); } if (finished) { return (
Plan complete 🎉
You've reached the end of your study plan. Take a final mock test or generate a new plan from Settings.
); } const dest = (kind) => { if (kind === 'vocab_new') return () => { update({ vocab: { ...state.vocab, filterMode: 'recommended' } }); setRoute('vocab'); }; if (kind === 'vocab_review') return () => { update({ vocab: { ...state.vocab, filterMode: 'review' } }); setRoute('vocab'); }; if (kind === 'grammar_lesson' || kind === 'grammar_quiz') return () => setRoute('grammar'); if (kind === 'reading_section' || kind === 'listening_section' || kind === 'writing_task' || kind === 'speaking_set' || kind === 'full_mock') return () => setRoute('mock'); return () => {}; }; return (
{week.label} · {week.focus}
Today's plan
Progress
{completion.done}/{completion.need}
{day.tasks.map((t, i) => { const done = window.planEngine.isTaskDone(t, state.dailyProgress?.[day.dateKey] || {}); return ( ); })}
); } function getGreeting() { const h = new Date().getHours(); return h < 12 ? 'morning' : h < 18 ? 'afternoon' : 'evening'; } function getMotivation(state) { if (state.streak.count >= 7) return `You're on a ${state.streak.count}-day streak. Extraordinary.`; if (state.streak.count > 1) return `${state.streak.count} days in a row. Keep the rhythm.`; if (state.vocab.learnedWords.length > 50) return `${state.vocab.learnedWords.length} words and counting.`; return 'Every session counts.'; } // ─── Vocabulary Browser ─────────────────────────────────────────────────── function Vocabulary({ state, update }) { const [filterMode, setFilterMode] = useState(state.vocab.filterMode || 'recommended'); const [flipped, setFlipped] = useState(false); const [index, setIndex] = useState(state.vocab.browseIndex || 0); const [search, setSearch] = useState(''); const [viewMode, setViewMode] = useState('flashcard'); const filtered = useMemo(() => { let list; if (filterMode === 'recommended') list = window.api.wordsForBand(state.targetBand); else if (filterMode === 'review') { const dueIds = window.srs.dueWords(state, { limit: 300 }); const seen = new Set(); const ids = [...dueIds, ...(state.vocab.learnedWords || [])].filter(id => { if (seen.has(id)) return false; seen.add(id); return true; }); list = ids.map(id => window.api.wordById(id)).filter(Boolean); } else if (window.IELTS_TOPICS && window.IELTS_TOPICS.some(t => t.id === filterMode)) list = window.getTopicWords(filterMode); else list = window.api.wordsByLevel(filterMode); if (search) { const q = search.toLowerCase(); list = list.filter(w => (w.w || '').toLowerCase().includes(q) || (w.b || '').includes(search.trim())); } return list; }, [filterMode, state.targetBand, search, state.vocab]); const current = filtered.length ? filtered[index % filtered.length] : null; const markLearned = (id) => { if (!id || state.vocab.learnedWords.includes(id)) return; let s = window.api.markLearned(state, id); s = window.srs.recordInteraction(s, id, 4); // graded "good" because reviewed s = window.planEngine.bumpProgress(s, 'vocabNew', 1); update(s); }; const next = () => { if (!filtered.length) return; const cur = filtered[index % filtered.length]; setFlipped(false); setIndex(i => (i + 1) % filtered.length); if (!cur) return; if (filterMode === 'review') { let s = window.srs.recordInteraction(state, cur.id, 4); s = window.planEngine.bumpProgress(s, 'vocabReview', 1); update(s); } else { markLearned(cur.id); } }; const prev = () => { if (!filtered.length) return; setFlipped(false); setIndex(i => (i - 1 + filtered.length) % filtered.length); }; const shuffle = () => { if (!filtered.length) return; setFlipped(false); setIndex(Math.floor(Math.random() * filtered.length)); }; useEffect(() => { setIndex(0); setFlipped(false); if (filterMode !== state.vocab.filterMode) { update({ vocab: { ...state.vocab, filterMode } }); } // eslint-disable-next-line }, [filterMode, search]); const cfg = window.bandConfig.for(state.targetBand); const recommendedLabel = cfg.levels.length === 1 ? `Recommended · level ${cfg.levels[0]}` : `Recommended · band ${state.targetBand}`; return (
Vocabulary · {filtered.length} {filtered.length === 1 ? 'word' : 'words'} {filterMode === 'review' ? 'to review' : 'available'}

{filterMode === 'review' ? 'Review words.' : 'Learn words.'}

{filterMode === 'review' ? 'Words you have already learned. Flip each card to test your memory, then press Next.' : 'Click a card to reveal the Bangla meaning. Spaced-repetition tracks what you\'ve seen.'}

{[1, 2, 3].map(l => ( ))}
setSearch(e.target.value)} />
{window.IELTS_TOPICS && window.IELTS_TOPICS.length > 0 && (
Topics: {window.IELTS_TOPICS.map(t => ( ))}
)} {!filtered.length &&
No words match this filter.
} {viewMode === 'flashcard' && current && ( <> setFlipped(f => !f)} />
{index + 1} / {filtered.length}
)} {viewMode === 'list' && filtered.length > 0 && (
{filtered.slice(0, 200).map((w, i) => (
{w.w}
{w.pos} · L{w.lvl}
{w.b}
{w.d || definition coming soon}
{window.api.isLearned(state, w.id) && learned}
))} {filtered.length > 200 &&
Showing first 200 of {filtered.length} — narrow your filter to see more.
}
)}
); } Object.assign(window, { Home, Vocabulary });