/* 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 (
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.chName} · Bài {nextLesson.no}
Hãy bắt đầu xây dựng đế chế 1 người của riêng bạn!
{passed}/{total} bài học đã hoàn thành