manifold/web/pages/index.tsx

60 lines
2.1 KiB
TypeScript
Raw Normal View History

import React, { useEffect } from 'react'
import { useRouter } from 'next/router'
import { useUser } from 'web/hooks/use-user'
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 { ManifoldLogo } from 'web/components/nav/manifold-logo'
import { redirectIfLoggedIn } from 'web/lib/firebase/server-auth'
export const getServerSideProps = redirectIfLoggedIn('/home', async (_) => {
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([
2022-06-15 23:05:25 +00:00
'will-max-go-to-prom-with-a-girl',
'will-ethereum-switch-to-proof-of-st',
2022-05-07 23:44:01 +00:00
'will-russia-control-the-majority-of',
'will-elon-musk-buy-twitter-this-yea',
2022-06-15 23:05:25 +00:00
'will-trump-be-charged-by-the-grand',
'will-spacex-launch-a-starship-into',
2022-05-07 23:44:01 +00:00
'who-will-win-the-nba-finals-champio',
2022-06-15 23:05:25 +00:00
'who-will-be-time-magazine-person-of',
'will-congress-hold-any-hearings-abo-e21f987033b3',
'will-at-least-10-world-cities-have',
2022-05-07 23:44:01 +00:00
])
return { props: { hotContracts } }
})
export default function Home(props: { hotContracts: Contract[] }) {
2022-01-23 00:16:23 +00:00
const { hotContracts } = props
// for now this redirect in the component is how we handle the case where they are
// on this page and they log in -- in the future we will make some cleaner way
const user = useUser()
const router = useRouter()
useEffect(() => {
if (user != null) {
router.replace('/home')
}
}, [router, user])
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
)
}