Skip to content

Commit 80a7bf5

Browse files
committed
fix(footer): fix footer in landing page to enter platform
1 parent 334f12c commit 80a7bf5

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

apps/sim/app/(landing)/components/sections/footer.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,36 @@ import Link from 'next/link'
55
import { useRouter } from 'next/navigation'
66
import { DiscordIcon, GithubIcon, xIcon as XIcon } from '@/components/icons'
77
import { Button } from '@/components/ui/button'
8+
import { useSession } from '@/lib/auth-client'
89
import useIsMobile from '../hooks/use-is-mobile'
910

10-
interface FooterProps {
11-
onOpenTypeformLink: () => void
12-
}
13-
14-
function Footer({ onOpenTypeformLink }: FooterProps) {
15-
const _router = useRouter()
11+
function Footer() {
12+
const router = useRouter()
1613
const { isMobile, mounted } = useIsMobile()
14+
const { data: session, isPending } = useSession()
15+
const isAuthenticated = !isPending && !!session?.user
16+
17+
const handleNavigate = () => {
18+
if (typeof window !== 'undefined') {
19+
// Check if user has an active session
20+
if (isAuthenticated) {
21+
router.push('/w')
22+
} else {
23+
// Check if user has logged in before
24+
const hasLoggedInBefore =
25+
localStorage.getItem('has_logged_in_before') === 'true' ||
26+
document.cookie.includes('has_logged_in_before=true')
27+
28+
if (hasLoggedInBefore) {
29+
// User has logged in before but doesn't have an active session
30+
router.push('/login')
31+
} else {
32+
// User has never logged in before
33+
router.push('/signup')
34+
}
35+
}
36+
}
37+
}
1738

1839
if (!mounted) {
1940
return <section className='flex w-full p-4 md:p-9' />
@@ -35,7 +56,7 @@ function Footer({ onOpenTypeformLink }: FooterProps) {
3556
className='w-fit bg-[#B5A1D4] text-[#1C1C1C] transition-colors duration-500 hover:bg-[#bdaecb]'
3657
size={'lg'}
3758
variant={'secondary'}
38-
onClick={onOpenTypeformLink}
59+
onClick={handleNavigate}
3960
>
4061
Get Started
4162
</Button>
@@ -196,7 +217,7 @@ function Footer({ onOpenTypeformLink }: FooterProps) {
196217
className='w-fit bg-[#B5A1D4] text-[#1C1C1C] transition-colors duration-500 hover:bg-[#bdaecb]'
197218
size={'lg'}
198219
variant={'secondary'}
199-
onClick={onOpenTypeformLink}
220+
onClick={handleNavigate}
200221
>
201222
Get Started
202223
</Button>

apps/sim/app/(landing)/landing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function Landing() {
2222
{/* <Blogs /> */}
2323

2424
{/* Footer */}
25-
<Footer onOpenTypeformLink={handleOpenTypeformLink} />
25+
<Footer />
2626
</main>
2727
)
2828
}

apps/sim/app/(landing)/privacy/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ export default function PrivacyPolicy() {
739739

740740
{/* Footer */}
741741
<div className='relative z-20'>
742-
<Footer onOpenTypeformLink={handleOpenTypeformLink} />
742+
<Footer />
743743
</div>
744744
</main>
745745
)

apps/sim/app/(landing)/terms/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export default function TermsOfService() {
360360

361361
{/* Footer */}
362362
<div className='relative z-20'>
363-
<Footer onOpenTypeformLink={handleOpenTypeformLink} />
363+
<Footer />
364364
</div>
365365
</main>
366366
)

0 commit comments

Comments
 (0)