import React from 'react';
import { GameState } from '../types';
interface LeaderboardProps {
gameState: GameState;
currentUserId: string;
}
export function Leaderboard({ gameState, currentUserId }: LeaderboardProps) {
const sortedUsers = Object.entries(gameState.users)
.sort(([, a], [, b]) => b.clicks - a.clicks)
.slice(0, 10);
return (
👑 BOZO LEADERBOARD 👑
{sortedUsers.map(([userId, user], index) => {
const isCurrentUser = userId === currentUserId;
const isTopThree = index < 3;
return (
{index === 0 ? '🥇' : index === 1 ? '🥈' : index === 2 ? '🥉' : `#${index + 1}`}
{user.name} {isCurrentUser ? '(You)' : ''}
{user.clicks.toLocaleString()}
);
})}
Total Players: {Object.keys(gameState.users).length}
);
}