da4ce99755
* Add dev target for TheoremOne * Restrict signups to theoremone.co emails * Add new indices * Forbid reads from unauthenticated users * Client-side render pages that need auth These pages are now client-side rendered: - /home - /leaderboards - /market/... - /fold/... * Hide 404 for private Manifolds * Brand instance for TheoremOne * Hide "Add Funds" and "Personalize your feed" * "M$" => "T$" * Hide Discord & About Page too * Update placeholders for teams * Update firestore.indexes.json * Switch /analytics to propz * Migrate per-env code into common/ * More migrations to PROJECT_ID * Conditionally use SSG depending on public vs private instance * Fix props to be empty object * Move more logic into access * Spin out config files for each environment * Generify most of the customizable brand stuff * Move IS_PRIVATE_MANIFOLD to access.ts * Rename access.ts to envs/constants.ts * Add "dev:dev" alias * Rever firestore rules to existing settings * Fixes according to James's review
64 lines
1.6 KiB
TypeScript
64 lines
1.6 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'
|
|
import { fromPropz, usePropz } from '../hooks/use-propz'
|
|
|
|
export const getStaticProps = fromPropz(getStaticPropz)
|
|
export async function getStaticPropz() {
|
|
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[]
|
|
}) {
|
|
props = usePropz(props, getStaticPropz) ?? {
|
|
topTraders: [],
|
|
topCreators: [],
|
|
}
|
|
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>
|
|
)
|
|
}
|