Skip to content

Commit

Permalink
remove user avatar for now (#11172)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-hariti authored Aug 28, 2024
1 parent a0c2568 commit d2eb8f0
Showing 1 changed file with 10 additions and 61 deletions.
71 changes: 10 additions & 61 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use client';

import {Fragment, useEffect, useState} from 'react';
import {Fragment} from 'react';
import {HamburgerMenuIcon} from '@radix-ui/react-icons';
import Image from 'next/image';
import Link from 'next/link';

import SentryLogoSVG from 'sentry-docs/logos/sentry-logo-dark.svg';

Expand All @@ -22,53 +21,7 @@ type Props = {
noSearch?: boolean;
};

type User = {
avatarUrl: string;
email: string;
id: string;
isActive: boolean;
name: string;
username: string;
};

function Avatar({user}: {user: User}) {
return (
<Link href="https://sentry.io" className="">
<div className="flex items-center space-x-2 px-4">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={user.avatarUrl}
alt={user.name}
width={32}
height={32}
className="rounded-full h-8 w-8"
/>
<div className="flex flex-col">
<span className="font-medium text-sm text-[var(--foreground)]">
{user.name}
</span>
<span className="text-xs text-[var(--foreground-secondary)]">
{user.username}
</span>
</div>
</div>
</Link>
);
}

export function Header({pathname, searchPlatforms, noSearch}: Props) {
// this should work on production (given the request is not blocked by ad blockers),
// but it doesn't on dev or previews because of CORS
// I implemeted a workaround in the form of an api route while building this
const [user, setUser] = useState<User | null>(null);
useEffect(() => {
fetch('https://sentry.io/api/0/users/me/', {credentials: 'include'})
.then(r => r.json())
.then(setUser)
// eslint-disable-next-line no-console
.catch(console.error);
}, []);

return (
<header className="bg-[var(--gray-1)] h-[var(--header-height)] w-full z-50 border-b border-[var(--gray-a3)] fixed top-0">
{/* define a header-height variable for consumption by other components */}
Expand Down Expand Up @@ -114,19 +67,15 @@ export function Header({pathname, searchPlatforms, noSearch}: Props) {
<div className="hidden lg-xl:flex justify-end flex-1 space-x-2 items-center min-w-fit">
<NavLink href="https://sentry.io/changelog/">Changelog</NavLink>
<NavLink href="https://try.sentry-demo.com/demo/start/">Sandbox</NavLink>
{user ? (
<Avatar user={user} />
) : (
<Fragment>
<NavLink href="https://sentry.io/">Sign In</NavLink>
<NavLink
href="https://sentry.io/signup/"
className="transition-all duration-300 ease-in-out hover:bg-gradient-to-r hover:from-[#fa7faa] hover:via-[#ff9691] hover:to-[#ffb287]"
>
Get Started
</NavLink>
</Fragment>
)}
<Fragment>
<NavLink href="https://sentry.io/">Sign In</NavLink>
<NavLink
href="https://sentry.io/signup/"
className="transition-all duration-300 ease-in-out hover:bg-gradient-to-r hover:from-[#fa7faa] hover:via-[#ff9691] hover:to-[#ffb287]"
>
Get Started
</NavLink>
</Fragment>
<ThemeToggle />
</div>
<div className="lg-xl:hidden ml-auto">
Expand Down

0 comments on commit d2eb8f0

Please sign in to comment.