'use client'; import type { Locale } from '@/lib/locale'; interface LeaderboardEntry { userId: number; userName: string | null; userEmail: string | null; totalAmount: number; orderCount: number; } interface LeaderboardProps { data: LeaderboardEntry[]; dark?: boolean; locale?: Locale; } const RANK_STYLES: Record = { 1: { light: 'bg-amber-100 text-amber-700', dark: 'bg-amber-500/20 text-amber-300' }, 2: { light: 'bg-slate-200 text-slate-600', dark: 'bg-slate-500/20 text-slate-300' }, 3: { light: 'bg-orange-100 text-orange-700', dark: 'bg-orange-500/20 text-orange-300' }, }; export default function Leaderboard({ data, dark, locale = 'zh' }: LeaderboardProps) { const title = locale === 'en' ? 'Recharge Leaderboard (Top 10)' : '充值排行榜 (Top 10)'; const emptyText = locale === 'en' ? 'No data' : '暂无数据'; const userLabel = locale === 'en' ? 'User' : '用户'; const amountLabel = locale === 'en' ? 'Total Amount' : '累计金额'; const orderCountLabel = locale === 'en' ? 'Orders' : '订单数'; const currency = locale === 'en' ? '$' : '¥'; const thCls = `px-4 py-3 text-left text-xs font-medium uppercase ${dark ? 'text-slate-400' : 'text-gray-500'}`; const tdCls = `whitespace-nowrap px-4 py-3 text-sm ${dark ? 'text-slate-300' : 'text-slate-700'}`; const tdMuted = `whitespace-nowrap px-4 py-3 text-sm ${dark ? 'text-slate-400' : 'text-gray-500'}`; if (data.length === 0) { return (

{title}

{emptyText}

); } return (

{title}

{data.map((entry, i) => { const rank = i + 1; const rankStyle = RANK_STYLES[rank]; return ( ); })}
# {userLabel} {amountLabel} {orderCountLabel}
{rankStyle ? ( {rank} ) : ( {rank} )}
{entry.userName || `#${entry.userId}`}
{entry.userEmail && (
{entry.userEmail}
)}
{currency}{entry.totalAmount.toLocaleString()} {entry.orderCount}
); }