Skip to content

Commit

Permalink
hide usernav if unauthenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzelei committed Oct 27, 2023
1 parent 4b1c492 commit 5e4d44d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions frontend/components/UserNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import { GearIcon } from '@radix-ui/react-icons';
import { signOut, useSession } from 'next-auth/react';
import { ReactElement } from 'react';

export function UserNav(): ReactElement {
export function UserNav(): ReactElement | null {
const session = useSession();

const avatarImageSrc = session.data?.user?.image ?? '';
const avatarImageAlt = session.data?.user?.name ?? 'unknown';
const avatarFallback = getAvatarFallback(session.data?.user?.name);

if (session.status === 'unauthenticated') {
return null;
}

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
disabled={session.status === 'unauthenticated'}
variant="ghost"
className="relative h-8 w-8 rounded-full"
>
<Button variant="ghost" className="relative h-8 w-8 rounded-full">
<Avatar className="h-8 w-8">
<AvatarImage src={avatarImageSrc} alt={avatarImageAlt} />
<AvatarFallback>{avatarFallback}</AvatarFallback>
Expand Down

0 comments on commit 5e4d44d

Please sign in to comment.