Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/api/airdrop/leaderboard/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function GET(req: NextRequest) {
.select("address, points");

if (!allPoints || allPoints.length === 0) {
return NextResponse.json({ entries: [], userRank: null });
return NextResponse.json({ entries: [], userRank: null, totalParticipants: 0 });
}

// Sum points by address
Expand Down Expand Up @@ -63,7 +63,7 @@ export async function GET(req: NextRequest) {
userRank = idx >= 0 ? idx + 1 : null;
}

return NextResponse.json({ entries, userRank }, {
return NextResponse.json({ entries, userRank, totalParticipants: pointsByAddress.size }, {
headers: { "Cache-Control": "public, s-maxage=30, stale-while-revalidate=15" },
});
}
3 changes: 2 additions & 1 deletion src/components/airdrop/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface LeaderboardEntry {
interface LeaderboardData {
entries: LeaderboardEntry[];
userRank: number | null;
totalParticipants: number;
}

function truncateAddress(addr: string) {
Expand Down Expand Up @@ -59,7 +60,7 @@ export function Leaderboard() {
<div className="border-border rounded border p-4">
<h3 className="text-foreground text-sm font-bold">Leaderboard</h3>
<div className="text-muted text-xs mb-3">
{data.entries.length} {data.entries.length === 1 ? "participant" : "participants"}
{data.totalParticipants} {data.totalParticipants === 1 ? "participant" : "participants"}
</div>

<div className="overflow-x-auto">
Expand Down
Loading