@@ -3,8 +3,9 @@ import { useRouter } from 'next/router'
33import React , { useState } from 'react'
44import { useWindowSize } from 'react-use'
55
6- import { useIsLoggedIn , useUser } from 'common'
6+ import { useIsLoggedIn , useIsUserLoading , useUser } from 'common'
77import { Button , buttonVariants , cn } from 'ui'
8+ import { AuthenticatedDropdownMenu } from 'ui-patterns'
89import {
910 NavigationMenu ,
1011 NavigationMenuContent ,
@@ -13,15 +14,14 @@ import {
1314 NavigationMenuList ,
1415 NavigationMenuTrigger ,
1516} from 'ui/src/components/shadcn/ui/navigation-menu'
16- import { AuthenticatedDropdownMenu } from 'ui-patterns'
1717
1818import ScrollProgress from 'components/ScrollProgress'
19+ import { useSendTelemetryEvent } from 'lib/telemetry'
1920import GitHubButton from './GitHubButton'
2021import HamburgerButton from './HamburgerMenu'
2122import MenuItem from './MenuItem'
2223import MobileMenu from './MobileMenu'
2324import RightClickBrandLogo from './RightClickBrandLogo'
24- import { useSendTelemetryEvent } from 'lib/telemetry'
2525import useDropdownMenu from './useDropdownMenu'
2626
2727import { getMenu } from 'data/nav'
@@ -35,12 +35,15 @@ const Nav = ({ hideNavbar, stickyNavbar = true }: Props) => {
3535 const router = useRouter ( )
3636 const { width } = useWindowSize ( )
3737 const [ open , setOpen ] = useState ( false )
38- const isLoggedIn = useIsLoggedIn ( )
3938 const menu = getMenu ( )
4039 const sendTelemetryEvent = useSendTelemetryEvent ( )
4140 const user = useUser ( )
4241 const userMenu = useDropdownMenu ( user )
4342
43+ const isLoggedIn = useIsLoggedIn ( )
44+ const isLoadingUser = useIsUserLoading ( )
45+ console . log ( { isLoadingUser, isLoggedIn } )
46+
4447 const isLaunchWeekPage = router . pathname . includes ( '/launch-week' )
4548 const isLaunchWeekXPage = router . pathname === '/launch-week/x'
4649 const isGAWeekSection = router . pathname . startsWith ( '/ga-week' )
@@ -126,47 +129,49 @@ const Nav = ({ hideNavbar, stickyNavbar = true }: Props) => {
126129 </ NavigationMenuList >
127130 </ NavigationMenu >
128131 </ div >
129- < div className = "flex items-center gap-2 opacity-0 animate-fade-in !scale-100 delay-300" >
130- < GitHubButton />
132+ { ! isLoadingUser && (
133+ < div className = "flex items-center gap-2 opacity-0 animate-fade-in !scale-100 delay-300" >
134+ < GitHubButton />
131135
132- { isLoggedIn ? (
133- < >
134- < Button className = "hidden lg:block" asChild >
135- < Link href = "/dashboard/projects" > Dashboard</ Link >
136- </ Button >
137- < AuthenticatedDropdownMenu menu = { userMenu } user = { user } site = "www" />
138- </ >
139- ) : (
140- < >
141- < Button type = "default" className = "hidden lg:block" asChild >
142- < Link
143- href = "https://supabase.com/dashboard"
144- onClick = { ( ) =>
145- sendTelemetryEvent ( {
146- action : 'sign_in_button_clicked' ,
147- properties : { buttonLocation : 'Header Nav' } ,
148- } )
149- }
150- >
151- Sign in
152- </ Link >
153- </ Button >
154- < Button className = "hidden lg:block" asChild >
155- < Link
156- href = "https://supabase.com/dashboard"
157- onClick = { ( ) =>
158- sendTelemetryEvent ( {
159- action : 'start_project_button_clicked' ,
160- properties : { buttonLocation : 'Header Nav' } ,
161- } )
162- }
163- >
164- Start your project
165- </ Link >
166- </ Button >
167- </ >
168- ) }
169- </ div >
136+ { isLoggedIn ? (
137+ < >
138+ < Button className = "hidden lg:block" asChild >
139+ < Link href = "/dashboard/projects" > Dashboard</ Link >
140+ </ Button >
141+ < AuthenticatedDropdownMenu menu = { userMenu } user = { user } site = "www" />
142+ </ >
143+ ) : (
144+ < >
145+ < Button type = "default" className = "hidden lg:block" asChild >
146+ < Link
147+ href = "https://supabase.com/dashboard"
148+ onClick = { ( ) =>
149+ sendTelemetryEvent ( {
150+ action : 'sign_in_button_clicked' ,
151+ properties : { buttonLocation : 'Header Nav' } ,
152+ } )
153+ }
154+ >
155+ Sign in
156+ </ Link >
157+ </ Button >
158+ < Button className = "hidden lg:block" asChild >
159+ < Link
160+ href = "https://supabase.com/dashboard"
161+ onClick = { ( ) =>
162+ sendTelemetryEvent ( {
163+ action : 'start_project_button_clicked' ,
164+ properties : { buttonLocation : 'Header Nav' } ,
165+ } )
166+ }
167+ >
168+ Start your project
169+ </ Link >
170+ </ Button >
171+ </ >
172+ ) }
173+ </ div >
174+ ) }
170175 </ div >
171176 < HamburgerButton
172177 toggleFlyOut = { ( ) => setOpen ( true ) }
0 commit comments