2022-05-09 13:04:36 +00:00
|
|
|
import { Col } from 'web/components/layout/col'
|
|
|
|
import { Leaderboard } from 'web/components/leaderboard'
|
|
|
|
import { Page } from 'web/components/page'
|
|
|
|
import { getTopCreators, getTopTraders, User } from 'web/lib/firebase/users'
|
|
|
|
import { formatMoney } from 'common/util/format'
|
|
|
|
import { fromPropz, usePropz } from 'web/hooks/use-propz'
|
2022-06-15 21:34:34 +00:00
|
|
|
import { useTracking } from 'web/hooks/use-tracking'
|
2022-01-18 03:20:25 +00:00
|
|
|
|
2022-03-09 02:43:30 +00:00
|
|
|
export const getStaticProps = fromPropz(getStaticPropz)
|
|
|
|
export async function getStaticPropz() {
|
2022-01-18 03:20:25 +00:00
|
|
|
const [topTraders, topCreators] = await Promise.all([
|
2022-06-13 04:42:41 +00:00
|
|
|
getTopTraders().catch(() => {}),
|
|
|
|
getTopCreators().catch(() => {}),
|
2022-01-18 03:20:25 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
topTraders,
|
|
|
|
topCreators,
|
|
|
|
},
|
|
|
|
|
|
|
|
revalidate: 60, // regenerate after a minute
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Leaderboards(props: {
|
|
|
|
topTraders: User[]
|
|
|
|
topCreators: User[]
|
|
|
|
}) {
|
2022-03-09 02:43:30 +00:00
|
|
|
props = usePropz(props, getStaticPropz) ?? {
|
|
|
|
topTraders: [],
|
|
|
|
topCreators: [],
|
|
|
|
}
|
2022-01-18 03:20:25 +00:00
|
|
|
const { topTraders, topCreators } = props
|
|
|
|
|
2022-06-15 21:34:34 +00:00
|
|
|
useTracking('view leaderboards')
|
|
|
|
|
2022-01-18 03:20:25 +00:00
|
|
|
return (
|
2022-06-16 21:43:34 +00:00
|
|
|
<Page>
|
|
|
|
<Col className="mx-4 items-center gap-10 lg:mx-0 lg:flex-row">
|
2022-01-18 03:20:25 +00:00
|
|
|
<Leaderboard
|
2022-04-26 14:42:45 +00:00
|
|
|
title="🏅 Top bettors"
|
2022-01-18 03:20:25 +00:00
|
|
|
users={topTraders}
|
|
|
|
columns={[
|
|
|
|
{
|
|
|
|
header: 'Total profit',
|
|
|
|
renderCell: (user) => formatMoney(user.totalPnLCached),
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
<Leaderboard
|
|
|
|
title="🏅 Top creators"
|
|
|
|
users={topCreators}
|
|
|
|
columns={[
|
|
|
|
{
|
2022-06-10 17:35:18 +00:00
|
|
|
header: 'Total bet',
|
2022-01-18 03:20:25 +00:00
|
|
|
renderCell: (user) => formatMoney(user.creatorVolumeCached),
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Page>
|
|
|
|
)
|
|
|
|
}
|