@@ -5,15 +5,36 @@ import Link from 'next/link'
55import { useRouter } from 'next/navigation'
66import { DiscordIcon , GithubIcon , xIcon as XIcon } from '@/components/icons'
77import { Button } from '@/components/ui/button'
8+ import { useSession } from '@/lib/auth-client'
89import 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 >
0 commit comments