import { Card } from '@/components/ui/card'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Badge } from '@/components/ui/badge'; import { LeaderboardContributor } from '@/types/contributor'; import { AchievementBadge, SpecialBadge } from './AchievementBadge'; import { Trophy, TrendingUp, Calendar } from 'lucide-react'; import { formatDistanceToNow } from 'date-fns'; interface LeaderboardEntryProps { contributor: LeaderboardContributor; showPeriodStats?: boolean; } export function LeaderboardEntry({ contributor, showPeriodStats = false }: LeaderboardEntryProps) { const periodStats = contributor.stats; const allTimeStats = contributor.total_stats; const totalContributions = showPeriodStats ? contributor.contribution_score : contributor.total_score; const getRankColor = (rank: number) => { if (rank === 1) return 'text-yellow-500'; if (rank === 2) return 'text-gray-400'; if (rank === 3) return 'text-orange-600'; return 'text-muted-foreground'; }; const getRankIcon = (rank: number) => { if (rank <= 3) { return ; } return null; }; return (
{/* Rank */}
{getRankIcon(contributor.rank)} #{contributor.rank}
{/* Avatar & Info */}
{(contributor.display_name || contributor.username).slice(0, 2).toUpperCase()}

{contributor.display_name || contributor.username}

Joined {formatDistanceToNow(new Date(contributor.join_date), { addSuffix: true })}
{/* Special Badges */} {contributor.special_badges.length > 0 && (
{contributor.special_badges.map((badge) => ( ))}
)}
{/* Stats Grid */}
{showPeriodStats ? ( <> {periodStats.parks_added > 0 && ( )} {periodStats.rides_added > 0 && ( )} {periodStats.photos_added > 0 && ( )} {periodStats.reviews_added > 0 && ( )} {periodStats.edits_made > 0 && ( )} ) : ( <> {allTimeStats.total_parks > 0 && ( )} {allTimeStats.total_rides > 0 && ( )} {allTimeStats.total_photos > 0 && ( )} {allTimeStats.total_reviews > 0 && ( )} {allTimeStats.total_edits > 0 && ( )} )}
{/* Total Score */}
Contribution Score
{totalContributions.toLocaleString()} pts
); } function StatCard({ label, value }: { label: string; value: number }) { return (
{label}
{value.toLocaleString()}
); }