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'
|
2022-06-22 16:05:54 +00:00
|
|
|
import {
|
|
|
|
getTopCreators,
|
|
|
|
getTopTraders,
|
|
|
|
getTopFollowed,
|
|
|
|
User,
|
|
|
|
} from 'web/lib/firebase/users'
|
2022-05-09 13:04:36 +00:00
|
|
|
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-06-22 16:05:54 +00:00
|
|
|
const [topTraders, topCreators, topFollowed] = await Promise.all([
|
2022-06-13 04:42:41 +00:00
|
|
|
getTopTraders().catch(() => {}),
|
|
|
|
getTopCreators().catch(() => {}),
|
2022-06-22 16:05:54 +00:00
|
|
|
getTopFollowed().catch(() => {}),
|
2022-01-18 03:20:25 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
topTraders,
|
|
|
|
topCreators,
|
2022-06-22 16:05:54 +00:00
|
|
|
topFollowed,
|
2022-01-18 03:20:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
revalidate: 60, // regenerate after a minute
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Leaderboards(props: {
|
|
|
|
topTraders: User[]
|
|
|
|
topCreators: User[]
|
2022-06-22 16:05:54 +00:00
|
|
|
topFollowed: User[]
|
2022-01-18 03:20:25 +00:00
|
|
|
}) {
|
2022-03-09 02:43:30 +00:00
|
|
|
props = usePropz(props, getStaticPropz) ?? {
|
|
|
|
topTraders: [],
|
|
|
|
topCreators: [],
|
2022-06-22 16:05:54 +00:00
|
|
|
topFollowed: [],
|
2022-03-09 02:43:30 +00:00
|
|
|
}
|
2022-06-22 16:05:54 +00:00
|
|
|
const { topTraders, topCreators, topFollowed } = props
|
2022-01-18 03:20:25 +00:00
|
|
|
|
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>
|
2022-06-22 16:05:54 +00:00
|
|
|
<Col className="mx-4 my-10 w-1/2 items-center gap-10 lg:mx-0 lg:flex-row">
|
|
|
|
<Leaderboard
|
|
|
|
title="👀 Most followed"
|
|
|
|
users={topFollowed}
|
|
|
|
columns={[
|
|
|
|
{
|
|
|
|
header: 'Number of followers',
|
|
|
|
renderCell: (user) => user.followerCountCached,
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</Col>
|
2022-01-18 03:20:25 +00:00
|
|
|
</Page>
|
|
|
|
)
|
|
|
|
}
|