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, getHotContracts } from '../lib/firebase/contracts'
|
2022-01-12 03:56:11 +00:00
|
|
|
import { Page } from '../components/page'
|
2022-01-23 00:16:23 +00:00
|
|
|
import { FeedPromo } from '../components/feed-create'
|
2022-01-21 18:33:58 +00:00
|
|
|
import { Col } from '../components/layout/col'
|
|
|
|
import { useUser } from '../hooks/use-user'
|
2021-12-01 04:20:13 +00:00
|
|
|
|
2021-12-19 05:59:34 +00:00
|
|
|
export async function getStaticProps() {
|
2022-01-23 00:16:23 +00:00
|
|
|
const hotContracts = (await getHotContracts().catch(() => [])) ?? []
|
2022-01-15 00:16:25 +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
|
2022-01-12 03:56:11 +00:00
|
|
|
|
2022-01-21 18:33:58 +00:00
|
|
|
const user = useUser()
|
|
|
|
|
2022-01-23 00:16:23 +00:00
|
|
|
if (user) {
|
|
|
|
Router.replace('/home')
|
|
|
|
return <></>
|
|
|
|
}
|
|
|
|
|
2022-01-12 03:56:11 +00:00
|
|
|
return (
|
|
|
|
<Page>
|
2022-01-21 18:33:58 +00:00
|
|
|
<Col className="items-center">
|
|
|
|
<Col className="max-w-3xl">
|
|
|
|
<div className="-mx-2 sm:mx-0">
|
2022-01-23 00:16:23 +00:00
|
|
|
<FeedPromo hotContracts={hotContracts ?? []} />
|
2022-01-21 18:33:58 +00:00
|
|
|
</div>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
2022-01-12 03:56:11 +00:00
|
|
|
</Page>
|
2022-01-05 06:32:52 +00:00
|
|
|
)
|
2021-12-17 04:44:48 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 23:49:46 +00:00
|
|
|
export default Home
|