Commit a2d98607 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: use redirect for landing (#6993)

* fix: use redirect for landing

* chore: rm console.log
parent 27d91529
......@@ -10,8 +10,9 @@ import { BaseButton } from 'components/Button'
import { AppleLogo } from 'components/Logo/AppleLogo'
import { useDisableNFTRoutes } from 'hooks/useDisableNFTRoutes'
import Swap from 'pages/Swap'
import { RedirectPathToSwapOnly } from 'pages/Swap/redirects'
import { parse } from 'qs'
import { useEffect, useMemo, useRef, useState } from 'react'
import { useEffect, useMemo, useRef } from 'react'
import { ArrowDownCircle } from 'react-feather'
import { useLocation, useNavigate } from 'react-router-dom'
import { Link as NativeLink } from 'react-router-dom'
......@@ -300,35 +301,28 @@ const Link = styled(NativeLink)`
export default function Landing() {
const isDarkMode = useIsDarkMode()
const cardsRef = useRef<HTMLDivElement>(null)
const [showContent, setShowContent] = useState(false)
const selectedWallet = useAppSelector((state) => state.user.selectedWallet)
const navigate = useNavigate()
const location = useLocation()
const queryParams = parse(location.search, {
ignoreQueryPrefix: true,
})
const shouldDisableNFTRoutes = useDisableNFTRoutes()
const cards = useMemo(
() => MAIN_CARDS.filter((card) => !(shouldDisableNFTRoutes && card.to.startsWith('/nft'))),
[shouldDisableNFTRoutes]
)
const [accountDrawerOpen] = useAccountDrawer()
const navigate = useNavigate()
useEffect(() => {
if ((queryParams.intro || !selectedWallet) && !accountDrawerOpen) {
setShowContent(true)
} else {
setShowContent(false)
if (accountDrawerOpen) {
setTimeout(() => {
navigate('/swap')
}, TRANSITION_DURATIONS.medium)
}, TRANSITION_DURATIONS.fast)
}
}, [navigate, selectedWallet, queryParams.intro, accountDrawerOpen])
}, [accountDrawerOpen, navigate])
const shouldDisableNFTRoutes = useDisableNFTRoutes()
const cards = useMemo(
() => MAIN_CARDS.filter((card) => !(shouldDisableNFTRoutes && card.to.startsWith('/nft'))),
[shouldDisableNFTRoutes]
)
const queryParams = parse(useLocation().search, { ignoreQueryPrefix: true })
if (selectedWallet && !queryParams.intro) {
return <RedirectPathToSwapOnly />
}
return (
<Trace page={InterfacePageName.LANDING_PAGE} shouldLogImpression>
......@@ -344,8 +338,6 @@ export default function Landing() {
</Link>
</TraceEvent>
</LandingSwapContainer>
{showContent && (
<>
<Gradient isDarkMode={isDarkMode} />
<GlowContainer>
<Glow />
......@@ -418,8 +410,6 @@ export default function Landing() {
<ProtocolBanner />
<AboutFooter />
</AboutContentContainer>
</>
)}
</PageContainer>
</Trace>
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment