diff --git a/web/components/leaderboard.tsx b/web/components/leaderboard.tsx index 5ab792b1..eb0fdcfc 100644 --- a/web/components/leaderboard.tsx +++ b/web/components/leaderboard.tsx @@ -17,43 +17,47 @@ export function Leaderboard(props: { return (
- <div className="overflow-x-auto"> - <table className="table table-zebra table-compact text-gray-500 w-full"> - <thead> - <tr className="p-2"> - <th>#</th> - <th>Name</th> - {columns.map((column) => ( - <th key={column.header}>{column.header}</th> - ))} - </tr> - </thead> - <tbody> - {users.map((user, index) => ( - <tr key={user.id}> - <td>{index + 1}</td> - <td> - <SiteLink className="relative" href={`/${user.username}`}> - <Row className="items-center gap-4"> - <img - className="rounded-full bg-gray-400 flex-shrink-0 ring-8 ring-gray-50" - src={user.avatarUrl || ''} - alt="" - width={32} - height={32} - /> - <div className="truncate">{user.name}</div> - </Row> - </SiteLink> - </td> + {users.length === 0 ? ( + <div className="text-gray-500 ml-2">None yet</div> + ) : ( + <div className="overflow-x-auto"> + <table className="table table-zebra table-compact text-gray-500 w-full"> + <thead> + <tr className="p-2"> + <th>#</th> + <th>Name</th> {columns.map((column) => ( - <td key={column.header}>{column.renderCell(user)}</td> + <th key={column.header}>{column.header}</th> ))} </tr> - ))} - </tbody> - </table> - </div> + </thead> + <tbody> + {users.map((user, index) => ( + <tr key={user.id}> + <td>{index + 1}</td> + <td> + <SiteLink className="relative" href={`/${user.username}`}> + <Row className="items-center gap-4"> + <img + className="rounded-full bg-gray-400 flex-shrink-0 ring-8 ring-gray-50" + src={user.avatarUrl || ''} + alt="" + width={32} + height={32} + /> + <div className="truncate">{user.name}</div> + </Row> + </SiteLink> + </td> + {columns.map((column) => ( + <td key={column.header}>{column.renderCell(user)}</td> + ))} + </tr> + ))} + </tbody> + </table> + </div> + )} </div> ) } diff --git a/web/pages/fold/[...slugs]/index.tsx b/web/pages/fold/[...slugs]/index.tsx index 01bbc6b5..5820e2de 100644 --- a/web/pages/fold/[...slugs]/index.tsx +++ b/web/pages/fold/[...slugs]/index.tsx @@ -99,7 +99,8 @@ async function toUserScores(userScores: { [userId: string]: number }) { const topUserPairs = _.take( _.sortBy(Object.entries(userScores), ([_, score]) => -1 * score), 10 - ) + ).filter(([_, score]) => score > 0) + const topUsers = await Promise.all( topUserPairs.map(([userId]) => getUser(userId)) )