2022-01-18 03:20:25 +00:00
|
|
|
import _ from 'lodash'
|
2022-01-30 21:51:30 +00:00
|
|
|
|
2022-01-18 03:20:25 +00:00
|
|
|
import { Col } from '../components/layout/col'
|
2022-01-21 23:21:46 +00:00
|
|
|
import { Leaderboard } from '../components/leaderboard'
|
2022-01-18 03:20:25 +00:00
|
|
|
import { Page } from '../components/page'
|
|
|
|
import { getTopCreators, getTopTraders, User } from '../lib/firebase/users'
|
2022-01-30 21:51:30 +00:00
|
|
|
import { formatMoney } from '../../common/util/format'
|
2022-01-18 03:20:25 +00:00
|
|
|
|
|
|
|
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 (
|
2022-01-27 22:43:45 +00:00
|
|
|
<Page margin>
|
2022-02-11 18:40:22 +00:00
|
|
|
<Col className="items-center gap-10 lg:flex-row">
|
2022-01-18 03:20:25 +00:00
|
|
|
<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>
|
|
|
|
)
|
|
|
|
}
|