manifold/web/pages/leaderboards.tsx
Austin Chen 7338bdd47a
Automatically sort Tailwind classes with Prettier (#45)
* Add Prettier Tailwind plugin

* Autoformat Tailwind classes with Prettier
2022-02-11 10:40:22 -08:00

58 lines
1.4 KiB
TypeScript

import _ from 'lodash'
import { Col } from '../components/layout/col'
import { Leaderboard } from '../components/leaderboard'
import { Page } from '../components/page'
import { getTopCreators, getTopTraders, User } from '../lib/firebase/users'
import { formatMoney } from '../../common/util/format'
export async function getStaticProps() {
const [topTraders, topCreators] = await Promise.all([
getTopTraders().catch((_) => {}),
getTopCreators().catch((_) => {}),
])
return {
props: {
topTraders,
topCreators,
},
revalidate: 60, // regenerate after a minute
}
}
export default function Leaderboards(props: {
topTraders: User[]
topCreators: User[]
}) {
const { topTraders, topCreators } = props
return (
<Page margin>
<Col className="items-center gap-10 lg:flex-row">
<Leaderboard
title="🏅 Top traders"
users={topTraders}
columns={[
{
header: 'Total profit',
renderCell: (user) => formatMoney(user.totalPnLCached),
},
]}
/>
<Leaderboard
title="🏅 Top creators"
users={topCreators}
columns={[
{
header: 'Market volume',
renderCell: (user) => formatMoney(user.creatorVolumeCached),
},
]}
/>
</Col>
</Page>
)
}