// React is used in JSX, TypeScript just doesn't detect it interface RankingUser { id: string; name: string; cost: number; share: number; isMe: boolean; rawStart: any; rawEnd: any; periodTokens: number; periodRequests: number; } interface RankingTableProps { ranking: RankingUser[]; title: string; } export function RankingTable({ ranking, title }: RankingTableProps) { const formatCurrency = (amount: number) => { return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 2, maximumFractionDigits: 2, }).format(amount); }; const formatPercentage = (ratio: number) => { return (ratio * 100).toFixed(2) + '%'; }; const formatNumber = (num: number) => { return new Intl.NumberFormat('en-US').format(num); }; const getRankBadge = (rank: number) => { if (rank === 1) { return ( 🥇 1st ); } if (rank === 2) { return ( 🥈 2nd ); } if (rank === 3) { return ( 🥉 3rd ); } return ( #{rank} ); }; return (

{title}

{ranking.map((user, index) => { const rank = index + 1; return ( ); })}
Rank User Cost Share Requests Tokens
{getRankBadge(rank)}
{user.name} {user.isMe && ( You )}
{formatCurrency(user.cost)}
{formatPercentage(user.share)}
{formatNumber(user.periodRequests)}
{formatNumber(user.periodTokens)}
{ranking.length === 0 && (

No data available

There are no users in this billing period.

)}
); }