Skip to content

Commit 3d66aee

Browse files
committed
fix(frontend): handle empty leaderboard edge case that caused crash
1 parent 16f7fc0 commit 3d66aee

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

learnmate-frontend/src/pages/Leaderboard.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,15 @@ const Leaderboard = () => {
272272
Keep Climbing! 🚀
273273
</h3>
274274
<p className="text-gray-600 dark:text-gray-400">
275-
You're {leaderboardData[6].rank - 7} places away from top 10. Complete more quizzes to climb!
275+
{userRank ? (
276+
userRank.rank > 10 ? (
277+
<>You're {userRank.rank - 10} places away from the top 10. Complete more quizzes to climb!</>
278+
) : (
279+
<>You're doing great! Keep maintaining your top 10 position!</>
280+
)
281+
) : (
282+
<>Start completing quizzes to join the leaderboard!</>
283+
)}
276284
</p>
277285
</div>
278286
<div className="flex items-center gap-2">

0 commit comments

Comments
 (0)