@@ -5,6 +5,7 @@ import Image from 'next/image'
55import Link from 'next/link'
66import { GithubOutlineIcon } from '@/components/icons'
77import { cn } from '@/lib/core/utils/cn'
8+ import { useSession } from '@/lib/auth/auth-client'
89import {
910 BlogDropdown ,
1011 type NavBlogPost ,
@@ -40,6 +41,9 @@ interface NavbarProps {
4041
4142export default function Navbar ( { logoOnly = false , blogPosts = [ ] } : NavbarProps ) {
4243 const brand = getBrandConfig ( )
44+ const { data : session , isPending : isSessionPending } = useSession ( )
45+ const isAuthenticated = Boolean ( session ?. user ?. id )
46+ const logoHref = isAuthenticated ? '/?home' : '/'
4347 const [ activeDropdown , setActiveDropdown ] = useState < DropdownId > ( null )
4448 const [ hoveredLink , setHoveredLink ] = useState < string | null > ( null )
4549 const [ mobileMenuOpen , setMobileMenuOpen ] = useState ( false )
@@ -92,7 +96,7 @@ export default function Navbar({ logoOnly = false, blogPosts = [] }: NavbarProps
9296 itemScope
9397 itemType = 'https://schema.org/SiteNavigationElement'
9498 >
95- < Link href = '/' className = { LOGO_CELL } aria-label = { `${ brand . name } home` } itemProp = 'url' >
99+ < Link href = { logoHref } className = { LOGO_CELL } aria-label = { `${ brand . name } home` } itemProp = 'url' >
96100 < span itemProp = 'name' className = 'sr-only' >
97101 { brand . name }
98102 </ span >
@@ -121,7 +125,11 @@ export default function Navbar({ logoOnly = false, blogPosts = [] }: NavbarProps
121125 { ! logoOnly && (
122126 < >
123127 < ul className = 'mt-[0.75px] hidden lg:flex' >
124- { NAV_LINKS . map ( ( { label, href, external, icon, dropdown } ) => {
128+ { NAV_LINKS . map ( ( { label, href : rawHref , external, icon, dropdown } ) => {
129+ const href =
130+ isAuthenticated && rawHref . startsWith ( '/#' )
131+ ? `/?home${ rawHref . slice ( 1 ) } `
132+ : rawHref
125133 const hasDropdown = ! ! dropdown
126134 const isActive = hasDropdown && activeDropdown === dropdown
127135 const isThisHovered = hoveredLink === label
@@ -206,21 +214,38 @@ export default function Navbar({ logoOnly = false, blogPosts = [] }: NavbarProps
206214
207215 < div className = 'hidden flex-1 lg:block' />
208216
209- < div className = 'hidden items-center gap-[8px] pr-[80px] pl-[20px] lg:flex' >
210- < Link
211- href = '/login'
212- className = 'inline-flex h-[30px] items-center rounded-[5px] border border-[#3d3d3d] px-[9px] text-[#ECECEC] text-[13.5px] transition-colors hover:bg-[#2A2A2A]'
213- aria-label = 'Log in'
214- >
215- Log in
216- </ Link >
217- < Link
218- href = '/signup'
219- className = 'inline-flex h-[30px] items-center gap-[7px] rounded-[5px] border border-[#FFFFFF] bg-[#FFFFFF] px-[9px] text-[13.5px] text-black transition-colors hover:border-[#E0E0E0] hover:bg-[#E0E0E0]'
220- aria-label = 'Get started with Sim'
221- >
222- Get started
223- </ Link >
217+ < div
218+ className = { cn (
219+ 'hidden items-center gap-[8px] pr-[80px] pl-[20px] lg:flex' ,
220+ isSessionPending && 'invisible'
221+ ) }
222+ >
223+ { isAuthenticated ? (
224+ < Link
225+ href = '/workspace'
226+ className = 'inline-flex h-[30px] items-center gap-[7px] rounded-[5px] border border-[#FFFFFF] bg-[#FFFFFF] px-[9px] text-[13.5px] text-black transition-colors hover:border-[#E0E0E0] hover:bg-[#E0E0E0]'
227+ aria-label = 'Go to app'
228+ >
229+ Go to App
230+ </ Link >
231+ ) : (
232+ < >
233+ < Link
234+ href = '/login'
235+ className = 'inline-flex h-[30px] items-center rounded-[5px] border border-[#3d3d3d] px-[9px] text-[#ECECEC] text-[13.5px] transition-colors hover:bg-[#2A2A2A]'
236+ aria-label = 'Log in'
237+ >
238+ Log in
239+ </ Link >
240+ < Link
241+ href = '/signup'
242+ className = 'inline-flex h-[30px] items-center gap-[7px] rounded-[5px] border border-[#FFFFFF] bg-[#FFFFFF] px-[9px] text-[13.5px] text-black transition-colors hover:border-[#E0E0E0] hover:bg-[#E0E0E0]'
243+ aria-label = 'Get started with Sim'
244+ >
245+ Get started
246+ </ Link >
247+ </ >
248+ ) }
224249 </ div >
225250
226251 < div className = 'flex flex-1 items-center justify-end pr-[20px] lg:hidden' >
@@ -242,7 +267,12 @@ export default function Navbar({ logoOnly = false, blogPosts = [] }: NavbarProps
242267 ) }
243268 >
244269 < ul className = 'flex flex-col' >
245- { NAV_LINKS . map ( ( { label, href, external } ) => (
270+ { NAV_LINKS . map ( ( { label, href : rawHref , external } ) => {
271+ const href =
272+ isAuthenticated && rawHref . startsWith ( '/#' )
273+ ? `/?home${ rawHref . slice ( 1 ) } `
274+ : rawHref
275+ return (
246276 < li key = { label } className = 'border-[#2A2A2A] border-b' >
247277 { external ? (
248278 < a
@@ -265,7 +295,8 @@ export default function Navbar({ logoOnly = false, blogPosts = [] }: NavbarProps
265295 </ Link >
266296 ) }
267297 </ li >
268- ) ) }
298+ )
299+ } ) }
269300 < li className = 'border-[#2A2A2A] border-b' >
270301 < a
271302 href = 'https://github.com/simstudioai/sim'
@@ -280,23 +311,36 @@ export default function Navbar({ logoOnly = false, blogPosts = [] }: NavbarProps
280311 </ li >
281312 </ ul >
282313
283- < div className = 'mt-auto flex flex-col gap-[10px] p-[20px]' >
284- < Link
285- href = '/login'
286- className = 'flex h-[32px] items-center justify-center rounded-[5px] border border-[#3d3d3d] text-[#ECECEC] text-[14px] transition-colors active:bg-[#2A2A2A]'
287- onClick = { ( ) => setMobileMenuOpen ( false ) }
288- aria-label = 'Log in'
289- >
290- Log in
291- </ Link >
292- < Link
293- href = '/signup'
294- className = 'flex h-[32px] items-center justify-center rounded-[5px] border border-[#FFFFFF] bg-[#FFFFFF] text-[14px] text-black transition-colors active:bg-[#E0E0E0]'
295- onClick = { ( ) => setMobileMenuOpen ( false ) }
296- aria-label = 'Get started with Sim'
297- >
298- Get started
299- </ Link >
314+ < div className = { cn ( 'mt-auto flex flex-col gap-[10px] p-[20px]' , isSessionPending && 'invisible' ) } >
315+ { isAuthenticated ? (
316+ < Link
317+ href = '/workspace'
318+ className = 'flex h-[32px] items-center justify-center rounded-[5px] border border-[#FFFFFF] bg-[#FFFFFF] text-[14px] text-black transition-colors active:bg-[#E0E0E0]'
319+ onClick = { ( ) => setMobileMenuOpen ( false ) }
320+ aria-label = 'Go to app'
321+ >
322+ Go to App
323+ </ Link >
324+ ) : (
325+ < >
326+ < Link
327+ href = '/login'
328+ className = 'flex h-[32px] items-center justify-center rounded-[5px] border border-[#3d3d3d] text-[#ECECEC] text-[14px] transition-colors active:bg-[#2A2A2A]'
329+ onClick = { ( ) => setMobileMenuOpen ( false ) }
330+ aria-label = 'Log in'
331+ >
332+ Log in
333+ </ Link >
334+ < Link
335+ href = '/signup'
336+ className = 'flex h-[32px] items-center justify-center rounded-[5px] border border-[#FFFFFF] bg-[#FFFFFF] text-[14px] text-black transition-colors active:bg-[#E0E0E0]'
337+ onClick = { ( ) => setMobileMenuOpen ( false ) }
338+ aria-label = 'Get started with Sim'
339+ >
340+ Get started
341+ </ Link >
342+ </ >
343+ ) }
300344 </ div >
301345 </ div >
302346 </ >
0 commit comments