manifold/web/pages/index.tsx

29 lines
641 B
TypeScript
Raw Normal View History

2021-12-03 01:18:00 +00:00
import React from 'react'
import { useUser } from '../hooks/use-user'
import Markets from './markets'
import LandingPage from './landing-page'
2021-12-19 05:59:34 +00:00
import { Contract, listAllContracts } from '../lib/firebase/contracts'
2021-12-19 05:59:34 +00:00
export async function getStaticProps() {
const contracts = await listAllContracts().catch((_) => [])
return {
props: {
contracts,
},
revalidate: 60, // regenerate after a minute
}
}
const Home = (props: { contracts: Contract[] }) => {
const user = useUser()
if (user === undefined) return <></>
2021-12-19 05:59:34 +00:00
return user ? <Markets contracts={props.contracts} /> : <LandingPage />
}
export default Home