'use client'; import { ENTRY_FEE_DINO, MAX_ATTEMPTS } from '../shared'; interface LeaderboardEntry { owner: string; score: string; } interface LeaderboardProps { leaderboard: LeaderboardEntry[]; loading: boolean; error: string | null; attemptsCount: number; } export default function Leaderboard({ leaderboard, loading, error, attemptsCount }: LeaderboardProps) { // Only show loading state if we have no data yet if (loading && leaderboard.length === 0) { return (

🏆 Leaderboard

); } if (error) { return (

🏆 Leaderboard

Failed to load leaderboard

); } // Sort leaderboard by score (highest first) const sortedLeaderboard = [...leaderboard].sort((a, b) => parseInt(b.score) - parseInt(a.score) ); return (

🏆 Leaderboard

{/* Combined Prize and Attempts Information */}

💰 Prize ({MAX_ATTEMPTS * ENTRY_FEE_DINO} DINO Total)

🎯 Attempts Remaining:
{MAX_ATTEMPTS - attemptsCount}
🥇 1st Place: {(MAX_ATTEMPTS * ENTRY_FEE_DINO * 0.8).toFixed(1)} DINO (80%)
🥈 2nd Place: {(MAX_ATTEMPTS * ENTRY_FEE_DINO * 0.1).toFixed(1)} DINO (10%)
🥉 3rd Place: {(MAX_ATTEMPTS * ENTRY_FEE_DINO * 0.05).toFixed(1)} DINO (5%)

Leaderboard resets after {MAX_ATTEMPTS} attempts

{sortedLeaderboard.length === 0 ? (

No scores yet. Be the first to play!

) : (
{sortedLeaderboard.map((entry, index) => (
{index + 1}

{entry.owner.length > 20 ? `${entry.owner.slice(0, 8)}...${entry.owner.slice(-8)}` : entry.owner }

{/* Prize indicators for top 3 */} {index < 3 && (
{index === 0 ? `🥇 ${(MAX_ATTEMPTS * ENTRY_FEE_DINO * 0.8).toFixed(1)} DINO Prize` : index === 1 ? `🥈 ${(MAX_ATTEMPTS * ENTRY_FEE_DINO * 0.1).toFixed(1)} DINO Prize` : `🥉 ${(MAX_ATTEMPTS * ENTRY_FEE_DINO * 0.05).toFixed(1)} DINO Prize` }
)}

{entry.score}

points

))}
)}

Updates every 5 seconds • {sortedLeaderboard.length} player{sortedLeaderboard.length !== 1 ? 's' : ''}

{loading && leaderboard.length > 0 && (
Refreshing...
)}
); }