1
1
'use client' ;
2
2
3
- import { Fragment , useEffect , useState } from 'react' ;
3
+ import { Fragment } from 'react' ;
4
4
import { HamburgerMenuIcon } from '@radix-ui/react-icons' ;
5
5
import Image from 'next/image' ;
6
- import Link from 'next/link' ;
7
6
8
7
import SentryLogoSVG from 'sentry-docs/logos/sentry-logo-dark.svg' ;
9
8
@@ -22,53 +21,7 @@ type Props = {
22
21
noSearch ?: boolean ;
23
22
} ;
24
23
25
- type User = {
26
- avatarUrl : string ;
27
- email : string ;
28
- id : string ;
29
- isActive : boolean ;
30
- name : string ;
31
- username : string ;
32
- } ;
33
-
34
- function Avatar ( { user} : { user : User } ) {
35
- return (
36
- < Link href = "https://sentry.io" className = "" >
37
- < div className = "flex items-center space-x-2 px-4" >
38
- { /* eslint-disable-next-line @next/next/no-img-element */ }
39
- < img
40
- src = { user . avatarUrl }
41
- alt = { user . name }
42
- width = { 32 }
43
- height = { 32 }
44
- className = "rounded-full h-8 w-8"
45
- />
46
- < div className = "flex flex-col" >
47
- < span className = "font-medium text-sm text-[var(--foreground)]" >
48
- { user . name }
49
- </ span >
50
- < span className = "text-xs text-[var(--foreground-secondary)]" >
51
- { user . username }
52
- </ span >
53
- </ div >
54
- </ div >
55
- </ Link >
56
- ) ;
57
- }
58
-
59
24
export function Header ( { pathname, searchPlatforms, noSearch} : Props ) {
60
- // this should work on production (given the request is not blocked by ad blockers),
61
- // but it doesn't on dev or previews because of CORS
62
- // I implemeted a workaround in the form of an api route while building this
63
- const [ user , setUser ] = useState < User | null > ( null ) ;
64
- useEffect ( ( ) => {
65
- fetch ( 'https://sentry.io/api/0/users/me/' , { credentials : 'include' } )
66
- . then ( r => r . json ( ) )
67
- . then ( setUser )
68
- // eslint-disable-next-line no-console
69
- . catch ( console . error ) ;
70
- } , [ ] ) ;
71
-
72
25
return (
73
26
< header className = "bg-[var(--gray-1)] h-[var(--header-height)] w-full z-50 border-b border-[var(--gray-a3)] fixed top-0" >
74
27
{ /* define a header-height variable for consumption by other components */ }
@@ -114,19 +67,15 @@ export function Header({pathname, searchPlatforms, noSearch}: Props) {
114
67
< div className = "hidden lg-xl:flex justify-end flex-1 space-x-2 items-center min-w-fit" >
115
68
< NavLink href = "https://sentry.io/changelog/" > Changelog</ NavLink >
116
69
< NavLink href = "https://try.sentry-demo.com/demo/start/" > Sandbox</ NavLink >
117
- { user ? (
118
- < Avatar user = { user } />
119
- ) : (
120
- < Fragment >
121
- < NavLink href = "https://sentry.io/" > Sign In</ NavLink >
122
- < NavLink
123
- href = "https://sentry.io/signup/"
124
- className = "transition-all duration-300 ease-in-out hover:bg-gradient-to-r hover:from-[#fa7faa] hover:via-[#ff9691] hover:to-[#ffb287]"
125
- >
126
- Get Started
127
- </ NavLink >
128
- </ Fragment >
129
- ) }
70
+ < Fragment >
71
+ < NavLink href = "https://sentry.io/" > Sign In</ NavLink >
72
+ < NavLink
73
+ href = "https://sentry.io/signup/"
74
+ className = "transition-all duration-300 ease-in-out hover:bg-gradient-to-r hover:from-[#fa7faa] hover:via-[#ff9691] hover:to-[#ffb287]"
75
+ >
76
+ Get Started
77
+ </ NavLink >
78
+ </ Fragment >
130
79
< ThemeToggle />
131
80
</ div >
132
81
< div className = "lg-xl:hidden ml-auto" >
0 commit comments