2021-12-03 01:18:00 +00:00
|
|
|
import React from 'react'
|
|
|
|
|
2021-12-15 07:24:55 +00:00
|
|
|
import { useUser } from '../hooks/use-user'
|
|
|
|
import Markets from './markets'
|
2021-12-18 01:47:39 +00:00
|
|
|
import LandingPage from './landing-page'
|
2021-12-19 05:59:34 +00:00
|
|
|
import { Contract, listAllContracts } from '../lib/firebase/contracts'
|
2021-12-01 04:20:13 +00:00
|
|
|
|
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[] }) => {
|
2021-12-15 07:24:55 +00:00
|
|
|
const user = useUser()
|
2021-12-17 03:37:36 +00:00
|
|
|
|
|
|
|
if (user === undefined) return <></>
|
2021-12-19 05:59:34 +00:00
|
|
|
|
|
|
|
return user ? <Markets contracts={props.contracts} /> : <LandingPage />
|
2021-12-17 04:44:48 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 23:49:46 +00:00
|
|
|
export default Home
|