diff --git a/src/components/creator/TipLeaderboard.tsx b/src/components/creator/TipLeaderboard.tsx new file mode 100644 index 00000000..83514d29 --- /dev/null +++ b/src/components/creator/TipLeaderboard.tsx @@ -0,0 +1,72 @@ +import { Trophy } from 'lucide-react'; +import { cn } from '@/lib/utils'; +import { formatNumber } from '@/utils/numberFormat.utils'; + +export interface TipLeaderboardEntry { + rank: number; + wallet: string; + totalTipped: number; + isAnonymous?: boolean; +} + +interface TipLeaderboardProps { + entries: TipLeaderboardEntry[]; + className?: string; +} + +const MEDAL: Record = { 1: '🥇', 2: '🥈', 3: '🥉' }; + +function truncateWallet(wallet: string): string { + if (wallet.length <= 12) return wallet; + return `${wallet.slice(0, 6)}…${wallet.slice(-4)}`; +} + +function LeaderboardRow({ entry }: { entry: TipLeaderboardEntry }) { + const medal = MEDAL[entry.rank]; + const label = entry.isAnonymous ? 'Anonymous' : truncateWallet(entry.wallet); + + return ( +
+ + {medal ?? entry.rank} + + + {label} + + + {formatNumber(entry.totalTipped)} XLM + +
+ ); +} + +export default function TipLeaderboard({ entries, className }: TipLeaderboardProps) { + if (!entries.length) return null; + + return ( +
+
+ +

Top Tippers

+
+
+ {entries.map(entry => ( +
+ +
+ ))} +
+
+ ); +}