From 7ffef0294a2d66ce40cdf816880b848a9d01d74d Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Thu, 31 Mar 2022 22:41:40 -0700 Subject: [PATCH] Grab up to 50 traders --- web/components/manaboard.tsx | 15 ++++++++++++++- web/lib/firebase/users.ts | 4 ++-- web/pages/leaderboards.tsx | 1 - 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/web/components/manaboard.tsx b/web/components/manaboard.tsx index 0a30ef0a..e4791353 100644 --- a/web/components/manaboard.tsx +++ b/web/components/manaboard.tsx @@ -21,7 +21,14 @@ export function Manaboard(props: { className?: string }) { // TODO: Ideally, highlight your own entry on the leaderboard - const { title, users, className, values } = props + let { title, users, className, values } = props + + const [expanded, setExpanded] = useState(false) + if (!expanded) { + users = users.slice(0, 25) + values = values.slice(0, 25) + } + return (
@@ -68,6 +75,12 @@ export function Manaboard(props: { ))} </tbody> </table> + <button + className="btn btn-sm btn-outline m-2" + onClick={() => setExpanded(!expanded)} + > + {expanded ? 'Hide' : 'Show more'} + </button> </div> )} </div> diff --git a/web/lib/firebase/users.ts b/web/lib/firebase/users.ts index 43253f45..f2689b48 100644 --- a/web/lib/firebase/users.ts +++ b/web/lib/firebase/users.ts @@ -160,12 +160,12 @@ export function listenForPrivateUsers( const topTradersQuery = query( collection(db, 'users'), orderBy('totalPnLCached', 'desc'), - limit(21) + limit(51) ) export async function getTopTraders() { const users = await getValues<User>(topTradersQuery) - return users.slice(0, 20) + return users.slice(0, 50) } const topCreatorsQuery = query( diff --git a/web/pages/leaderboards.tsx b/web/pages/leaderboards.tsx index 49c9c4eb..e700b525 100644 --- a/web/pages/leaderboards.tsx +++ b/web/pages/leaderboards.tsx @@ -98,7 +98,6 @@ function Explanation() { // [ ] Correctly calculate tax // [ ] List history of purchases at the bottom // [ ] Restrict to at most buying one slot per user? -// [ ] Set to 50 top traders // [ ] Deduct amount from user's balance, either in UX or for real export default function Manaboards(props: { topTraders: User[]