diff --git a/src/app/leaderboard/page.tsx b/src/app/leaderboard/page.tsx index e8e77c0..647022a 100644 --- a/src/app/leaderboard/page.tsx +++ b/src/app/leaderboard/page.tsx @@ -1,39 +1,73 @@ import { mockLeaderboard } from "@/data/mock-leaderboard"; +type SortKey = "earned"; + +function formatUsd(value: number) { + return new Intl.NumberFormat("en-US", { + style: "currency", + currency: "USD", + maximumFractionDigits: 0, + }).format(value); +} + export default function LeaderboardPage() { - const sorted = [...mockLeaderboard].sort((a, b) => b.earned - a.earned); + const sortBy: SortKey = "earned"; + const sorted = [...mockLeaderboard].sort((a, b) => { + if (b[sortBy] !== a[sortBy]) return b[sortBy] - a[sortBy]; + if (b.reputation !== a.reputation) return b.reputation - a.reputation; + return b.bounties - a.bounties; + }); return ( -
-
+
+

Leaderboard

-

- Build a leaderboard UI with sorting and ranking logic. +

+ Ranked by total earned. Includes completed bounties and reputation score.

-
-
-
Rank
-
Developer
-
Bounties
-
Total Earned
+
+
+
Rank
+
Developer
+
Bounties
+
Total earned
+
Reputation
+
+ +
+ {sorted.map((dev, index) => ( +
+
+
+ + #{index + 1} + +
+ +
+
{dev.name}
+
+ +
+
{dev.bounties}
+
completed
+
+ +
+
{formatUsd(dev.earned)}
+
+ +
+
{dev.reputation}
+
score
+
+
+
+ ))}
- {sorted.map((dev, index) => ( -
-
#{index + 1}
-
-
{dev.name}
-
Reputation {dev.reputation}
-
-
{dev.bounties}
-
${dev.earned.toLocaleString()}
-
- ))}
-
+
); }