Change index page to redirect for authed users
This commit is contained in:
parent
cedc1c3be5
commit
6234083d09
|
@ -8,7 +8,19 @@ import { Col } from 'web/components/layout/col'
|
||||||
import { useUser } from 'web/hooks/use-user'
|
import { useUser } from 'web/hooks/use-user'
|
||||||
import { ManifoldLogo } from 'web/components/nav/manifold-logo'
|
import { ManifoldLogo } from 'web/components/nav/manifold-logo'
|
||||||
|
|
||||||
export async function getStaticProps() {
|
import { GetServerSideProps } from 'next'
|
||||||
|
import { getServerAuthenticatedUid } from 'web/lib/firebase/server-auth'
|
||||||
|
|
||||||
|
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||||
|
const uid = await getServerAuthenticatedUid(ctx)
|
||||||
|
if (uid != null) {
|
||||||
|
return {
|
||||||
|
redirect: {
|
||||||
|
destination: '/home',
|
||||||
|
permanent: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
// These hardcoded markets will be shown in the frontpage for signed-out users:
|
// These hardcoded markets will be shown in the frontpage for signed-out users:
|
||||||
const hotContracts = await getContractsBySlugs([
|
const hotContracts = await getContractsBySlugs([
|
||||||
'will-max-go-to-prom-with-a-girl',
|
'will-max-go-to-prom-with-a-girl',
|
||||||
|
@ -22,14 +34,10 @@ export async function getStaticProps() {
|
||||||
'will-congress-hold-any-hearings-abo-e21f987033b3',
|
'will-congress-hold-any-hearings-abo-e21f987033b3',
|
||||||
'will-at-least-10-world-cities-have',
|
'will-at-least-10-world-cities-have',
|
||||||
])
|
])
|
||||||
|
return { props: { hotContracts } }
|
||||||
return {
|
|
||||||
props: { hotContracts },
|
|
||||||
revalidate: 60, // regenerate after a minute
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Home = (props: { hotContracts: Contract[] }) => {
|
export default function Home(props: { hotContracts: Contract[] }) {
|
||||||
const { hotContracts } = props
|
const { hotContracts } = props
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
@ -58,5 +66,3 @@ const Home = (props: { hotContracts: Contract[] }) => {
|
||||||
</Page>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Home
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user