diff --git a/src/app/leaderboard/page.tsx b/src/app/leaderboard/page.tsx index e8e77c0..bf81a30 100644 --- a/src/app/leaderboard/page.tsx +++ b/src/app/leaderboard/page.tsx @@ -1,7 +1,26 @@ import { mockLeaderboard } from "@/data/mock-leaderboard"; export default function LeaderboardPage() { - const sorted = [...mockLeaderboard].sort((a, b) => b.earned - a.earned); + const sorted = [...mockLeaderboard].sort((a, b) => { + if (b.earned !== a.earned) return b.earned - a.earned; + if (b.bounties !== a.bounties) return b.bounties - a.bounties; + return a.name.localeCompare(b.name); + }); + + const getRank = (index: number) => { + if (index === 0) return 1; + const current = sorted[index]; + const prev = sorted[index - 1]; + + if ( + current.earned === prev.earned && + current.bounties === prev.bounties + ) { + return getRank(index - 1); + } + + return index + 1; + }; return (
@@ -13,24 +32,38 @@ export default function LeaderboardPage() {
-
+
Rank
Developer
Bounties
Total Earned
+ +
+ Top Developers +
+ {sorted.map((dev, index) => (
-
#{index + 1}
-
-
{dev.name}
+
#{getRank(index)}
+ +
+
{dev.name}
Reputation {dev.reputation}
-
{dev.bounties}
-
${dev.earned.toLocaleString()}
+ +
+ Bounties: + {dev.bounties} +
+ +
+ Earned: + ${dev.earned.toLocaleString()} +
))}
diff --git a/src/components/bounty-card.tsx b/src/components/bounty-card.tsx index ba1c467..51ca9b4 100644 --- a/src/components/bounty-card.tsx +++ b/src/components/bounty-card.tsx @@ -7,14 +7,17 @@ type BountyCardProps = { }; const difficultyStyles = { - Easy: "bg-emerald-50 text-emerald-700 border-emerald-200", - Medium: "bg-amber-50 text-amber-700 border-amber-200", - Hard: "bg-rose-50 text-rose-700 border-rose-200", + Easy: "bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-900/20 dark:text-emerald-300 dark:border-emerald-800", + Medium: + "bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-900/20 dark:text-amber-300 dark:border-amber-800", + Hard: "bg-rose-50 text-rose-700 border-rose-200 dark:bg-rose-900/20 dark:text-rose-300 dark:border-rose-800", }; export function BountyCard({ title, reward, tags, difficulty, progress }: BountyCardProps) { + const clampedProgress = Math.max(0, Math.min(100, progress)); + return ( -
+

{title}

@@ -27,24 +30,25 @@ export function BountyCard({ title, reward, tags, difficulty, progress }: Bounty
-
${reward}
- +

Reward

+
${reward}
+ {difficulty}
+
-
+
Progress - {progress}% + {clampedProgress}%
-
-
+
+
-
+ ); }