Hide negative earners on leaderboard. Show empty message if none on leaderboard.
This commit is contained in:
parent
764790c1e1
commit
53a6748c6d
|
@ -17,6 +17,9 @@ export function Leaderboard(props: {
|
||||||
return (
|
return (
|
||||||
<div className={clsx('w-full px-1', className)}>
|
<div className={clsx('w-full px-1', className)}>
|
||||||
<Title text={title} />
|
<Title text={title} />
|
||||||
|
{users.length === 0 ? (
|
||||||
|
<div className="text-gray-500 ml-2">None yet</div>
|
||||||
|
) : (
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
<table className="table table-zebra table-compact text-gray-500 w-full">
|
<table className="table table-zebra table-compact text-gray-500 w-full">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -54,6 +57,7 @@ export function Leaderboard(props: {
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,8 @@ async function toUserScores(userScores: { [userId: string]: number }) {
|
||||||
const topUserPairs = _.take(
|
const topUserPairs = _.take(
|
||||||
_.sortBy(Object.entries(userScores), ([_, score]) => -1 * score),
|
_.sortBy(Object.entries(userScores), ([_, score]) => -1 * score),
|
||||||
10
|
10
|
||||||
)
|
).filter(([_, score]) => score > 0)
|
||||||
|
|
||||||
const topUsers = await Promise.all(
|
const topUsers = await Promise.all(
|
||||||
topUserPairs.map(([userId]) => getUser(userId))
|
topUserPairs.map(([userId]) => getUser(userId))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user