manifold/web/pages/index.tsx

63 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-12-03 01:18:00 +00:00
import React from 'react'
2022-01-23 00:16:23 +00:00
import Router from 'next/router'
import { Contract, getContractsBySlugs } from 'web/lib/firebase/contracts'
import { Page } from 'web/components/page'
2022-06-13 16:19:46 +00:00
import { LandingPagePanel } from 'web/components/landing-page-panel'
import { Col } from 'web/components/layout/col'
import { useUser } from 'web/hooks/use-user'
import { ManifoldLogo } from 'web/components/nav/manifold-logo'
2021-12-19 05:59:34 +00:00
export async function getStaticProps() {
2022-05-10 17:03:53 +00:00
// These hardcoded markets will be shown in the frontpage for signed-out users:
2022-05-07 23:44:01 +00:00
const hotContracts = await getContractsBySlugs([
'if-boris-johnson-is-leader-of-the-c',
'will-ethereum-merge-to-proofofstake',
'will-russia-control-the-majority-of',
'will-elon-musk-buy-twitter-this-yea',
'will-an-ai-get-gold-on-any-internat',
'how-many-us-supreme-court-justices',
'who-will-win-the-nba-finals-champio',
'what-database-will-manifold-be-prim',
2022-05-10 17:03:53 +00:00
'will-the-supreme-court-leakers-iden',
'will-over-25-of-participants-in-the-163d54309e43',
2022-05-07 23:44:01 +00:00
])
2021-12-19 05:59:34 +00:00
return {
2022-01-23 00:16:23 +00:00
props: { hotContracts },
2021-12-19 05:59:34 +00:00
revalidate: 60, // regenerate after a minute
}
}
2022-01-23 00:16:23 +00:00
const Home = (props: { hotContracts: Contract[] }) => {
const { hotContracts } = props
const user = useUser()
2022-01-23 00:16:23 +00:00
if (user) {
Router.replace('/home')
return <></>
}
return (
<Page>
<div className="px-4 pt-2 md:mt-0 lg:hidden">
<ManifoldLogo />
</div>
<Col className="items-center">
<Col className="max-w-3xl">
2022-06-13 16:19:46 +00:00
<LandingPagePanel hotContracts={hotContracts ?? []} />
{/* <p className="mt-6 text-gray-500">
2022-03-25 05:53:12 +00:00
View{' '}
<SiteLink href="/markets" className="font-bold text-gray-700">
all markets
</SiteLink>
</p> */}
</Col>
</Col>
</Page>
2022-01-05 06:32:52 +00:00
)
}
export default Home