/* Tiến độ theo chương + bài học tiếp theo (Duolingo & Khan Academy) */ function ProfileStatsProgress({ curr, rankInfo, go, profile, setTab }) { if (!curr || !curr.chapters) return null; const flat = curr.chapters.flatMap((ch) => (ch.lessons || []).map((l) => Object.assign({}, l, { ch: ch.ch, chName: ch.name })) ); const nextLesson = flat.find((l) => l.unlocked && !l.done) || flat.find((l) => !l.done) || null; const allDone = flat.length > 0 && flat.every((l) => l.done); const totalLessons = flat.length; const passedLessons = flat.filter((l) => l.done).length; const pct = totalLessons > 0 ? Math.round((passedLessons / totalLessons) * 100) : 0; const streak = rankInfo ? rankInfo.streak || 0 : 0; const handleStudy = (lesson) => { if (!lesson) return; location.hash = `#hoc/phan-${lesson.ch}/bai-${lesson.no}`; if (go) go("learn"); }; const triggerCelebrate = () => { if (window.fireworks) window.fireworks(true); if (window.dcpBigWin) window.dcpBigWin("Chúc mừng bạn đã hoàn thành tất cả bài học xuất sắc! 🎉"); }; return (
{streak > 0 && (
🔥

Đừng để đứt chuỗi {streak} ngày!

Học ít nhất 1 bài hôm nay để giữ ngọn lửa. Chỉ cần 5–10 phút là đủ!

)} {nextLesson && !allDone && (
BÀI HỌC TIẾP THEO

{nextLesson.title}

{nextLesson.chName} · Bài {nextLesson.no}

)} {allDone && (
🏆 XUẤT SẮC

Chúc mừng! Bạn đã hoàn thành tất cả bài học.

Hãy bắt đầu xây dựng đế chế 1 người của riêng bạn!

)}

📊 Bản đồ tiến độ theo chương

{curr.chapters.map((ch) => { const total = ch.lessons ? ch.lessons.length : 0; const passed = ch.lessons ? ch.lessons.filter((l) => l.done).length : 0; const chPct = total > 0 ? Math.round((passed / total) * 100) : 0; return (

{ch.name}

{chPct}%

{passed}/{total} bài học đã hoàn thành

); })}
); } Object.assign(window, { ProfileStatsProgress });