From 80a7bf5e5f61b43228cd6a26db338bc4801956a9 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 26 May 2025 18:46:06 -0700 Subject: [PATCH] fix(footer): fix footer in landing page to enter platform --- .../(landing)/components/sections/footer.tsx | 37 +++++++++++++++---- apps/sim/app/(landing)/landing.tsx | 2 +- apps/sim/app/(landing)/privacy/page.tsx | 2 +- apps/sim/app/(landing)/terms/page.tsx | 2 +- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/apps/sim/app/(landing)/components/sections/footer.tsx b/apps/sim/app/(landing)/components/sections/footer.tsx index 333192e48a..3010752a3d 100644 --- a/apps/sim/app/(landing)/components/sections/footer.tsx +++ b/apps/sim/app/(landing)/components/sections/footer.tsx @@ -5,15 +5,36 @@ import Link from 'next/link' import { useRouter } from 'next/navigation' import { DiscordIcon, GithubIcon, xIcon as XIcon } from '@/components/icons' import { Button } from '@/components/ui/button' +import { useSession } from '@/lib/auth-client' import useIsMobile from '../hooks/use-is-mobile' -interface FooterProps { - onOpenTypeformLink: () => void -} - -function Footer({ onOpenTypeformLink }: FooterProps) { - const _router = useRouter() +function Footer() { + const router = useRouter() const { isMobile, mounted } = useIsMobile() + const { data: session, isPending } = useSession() + const isAuthenticated = !isPending && !!session?.user + + const handleNavigate = () => { + if (typeof window !== 'undefined') { + // Check if user has an active session + if (isAuthenticated) { + router.push('/w') + } else { + // Check if user has logged in before + const hasLoggedInBefore = + localStorage.getItem('has_logged_in_before') === 'true' || + document.cookie.includes('has_logged_in_before=true') + + if (hasLoggedInBefore) { + // User has logged in before but doesn't have an active session + router.push('/login') + } else { + // User has never logged in before + router.push('/signup') + } + } + } + } if (!mounted) { return
@@ -35,7 +56,7 @@ function Footer({ onOpenTypeformLink }: FooterProps) { className='w-fit bg-[#B5A1D4] text-[#1C1C1C] transition-colors duration-500 hover:bg-[#bdaecb]' size={'lg'} variant={'secondary'} - onClick={onOpenTypeformLink} + onClick={handleNavigate} > Get Started @@ -196,7 +217,7 @@ function Footer({ onOpenTypeformLink }: FooterProps) { className='w-fit bg-[#B5A1D4] text-[#1C1C1C] transition-colors duration-500 hover:bg-[#bdaecb]' size={'lg'} variant={'secondary'} - onClick={onOpenTypeformLink} + onClick={handleNavigate} > Get Started diff --git a/apps/sim/app/(landing)/landing.tsx b/apps/sim/app/(landing)/landing.tsx index cbe2a482f5..1965b454d2 100644 --- a/apps/sim/app/(landing)/landing.tsx +++ b/apps/sim/app/(landing)/landing.tsx @@ -22,7 +22,7 @@ export default function Landing() { {/* */} {/* Footer */} -