43 lines
988 B
TypeScript
43 lines
988 B
TypeScript
import React from 'react'
|
|
import Router from 'next/router'
|
|
|
|
import { Contract, getHotContracts } from '../lib/firebase/contracts'
|
|
import { Page } from '../components/page'
|
|
import { FeedPromo } from '../components/feed-create'
|
|
import { Col } from '../components/layout/col'
|
|
import { useUser } from '../hooks/use-user'
|
|
|
|
export async function getStaticProps() {
|
|
const hotContracts = (await getHotContracts().catch(() => [])) ?? []
|
|
|
|
return {
|
|
props: { hotContracts },
|
|
revalidate: 60, // regenerate after a minute
|
|
}
|
|
}
|
|
|
|
const Home = (props: { hotContracts: Contract[] }) => {
|
|
const { hotContracts } = props
|
|
|
|
const user = useUser()
|
|
|
|
if (user) {
|
|
Router.replace('/home')
|
|
return <></>
|
|
}
|
|
|
|
return (
|
|
<Page>
|
|
<Col className="items-center">
|
|
<Col className="max-w-3xl">
|
|
<div className="-mx-2 sm:mx-0">
|
|
<FeedPromo hotContracts={hotContracts ?? []} />
|
|
</div>
|
|
</Col>
|
|
</Col>
|
|
</Page>
|
|
)
|
|
}
|
|
|
|
export default Home
|