// Grammar Learn — sectioned step-by-step lessons with Bangla // Uses window.api for grammar sections/lessons. function GrammarLearn({ state, update }) { const [openSection, setOpenSection] = useState(null); const [activeLesson, setActiveLesson] = useState(null); const [showBn, setShowBn] = useState(true); const sections = window.api.grammarSections(); const lessons = window.api.grammarLessons(); const learned = state.grammarLearn?.learned || {}; const lessonsBySection = useMemo(() => { const map = {}; for (const s of sections) map[s.id] = lessons.filter(l => l.section === s.id); return map; }, [sections, lessons]); const markLearned = (id) => { let s = { ...state, grammarLearn: { ...(state.grammarLearn || {}), learned: { ...learned, [id]: Date.now() }, }, }; if (!learned[id]) s = window.planEngine.bumpProgress(s, 'grammarLessons', 1); update(s); }; // ── Lesson detail view ── if (activeLesson) { const l = lessons.find(x => x.id === activeLesson); if (!l) { setActiveLesson(null); return null; } const isLearned = !!learned[l.id]; const sectionMeta = sections.find(s => s.id === l.section); const sameSection = lessonsBySection[l.section] || []; const idx = sameSection.findIndex(x => x.id === l.id); const prev = idx > 0 ? sameSection[idx - 1] : null; const next = idx < sameSection.length - 1 ? sameSection[idx + 1] : null; return (
{sectionMeta?.title} · Lesson {idx + 1} of {sameSection.length}

{l.title}

{l.titleBn}

{l.summary}

{showBn &&

{l.summaryBn}

}
{l.blocks.map((b, i) => )}
{prev && } {next && }
); } // ── Section browser ── const totalLessons = lessons.length; const learnedCount = Object.keys(learned).length; return (
Grammar · Learn

Grammar, made simple.

Only what IELTS actually tests. Pick a topic, read the rule, see real examples with Bangla meaning.

{learnedCount}/{totalLessons}
lessons learned
{sections.map(s => { const list = lessonsBySection[s.id] || []; const doneInSection = list.filter(l => learned[l.id]).length; const isOpen = openSection === s.id; return (
{isOpen && (
{list.map(l => ( ))}
)}
); })}
); } function LessonBlock({ block, showBn }) { if (block.kind === 'rule') { return (
Rule
{block.text}
{showBn && block.textBn &&
{block.textBn}
}
); } if (block.kind === 'tip') { return (
💡 Tip
{block.text}
{showBn && block.textBn &&
{block.textBn}
}
); } if (block.kind === 'examples') { return (
Examples
{block.items.map((it, i) => (
{it.en}
{showBn &&
{it.bn}
}
))}
); } if (block.kind === 'compare') { return (
Compare
✗ Wrong
{block.a}
✓ Right
{block.b}
{block.note &&
{block.note}
}
); } return null; } Object.assign(window, { GrammarLearn });