Redirect home on sign in
This commit is contained in:
parent
ffa74c8e10
commit
90c707516b
|
@ -6,6 +6,9 @@ import { ManifoldLogo } from 'web/components/nav/manifold-logo'
|
||||||
import { redirectIfLoggedIn } from 'web/lib/firebase/server-auth'
|
import { redirectIfLoggedIn } from 'web/lib/firebase/server-auth'
|
||||||
import { useSaveReferral } from 'web/hooks/use-save-referral'
|
import { useSaveReferral } from 'web/hooks/use-save-referral'
|
||||||
import { SEO } from 'web/components/SEO'
|
import { SEO } from 'web/components/SEO'
|
||||||
|
import { useUser } from 'web/hooks/use-user'
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
|
||||||
export const getServerSideProps = redirectIfLoggedIn('/home', async (_) => {
|
export const getServerSideProps = redirectIfLoggedIn('/home', async (_) => {
|
||||||
// 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:
|
||||||
|
@ -29,6 +32,15 @@ export default function Home(props: { hotContracts: Contract[] }) {
|
||||||
|
|
||||||
useSaveReferral()
|
useSaveReferral()
|
||||||
|
|
||||||
|
const user = useUser()
|
||||||
|
const router = useRouter()
|
||||||
|
useEffect(() => {
|
||||||
|
if (user) {
|
||||||
|
// Redirect to the /home page if the user is logged in.
|
||||||
|
router.push('/home')
|
||||||
|
}
|
||||||
|
}, [user, router])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<SEO
|
<SEO
|
||||||
|
|
Loading…
Reference in New Issue
Block a user