"use client"; import Image from "next/image"; import Link from "next/link"; import { useState } from "react"; import { SignOutButton, useUser } from "@/auth/clerk"; import { Activity, Bot, ChevronDown, LayoutDashboard, LogOut, Plus, Server, Settings, Trello, } from "lucide-react"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { cn } from "@/lib/utils"; type UserMenuProps = { className?: string; displayName?: string; displayEmail?: string; }; export function UserMenu({ className, displayName: displayNameFromDb, displayEmail: displayEmailFromDb, }: UserMenuProps) { const [open, setOpen] = useState(false); const { user } = useUser(); if (!user) return null; const avatarUrl = user.imageUrl ?? null; const avatarLabelSource = displayNameFromDb ?? user.id ?? "U"; const avatarLabel = avatarLabelSource.slice(0, 1).toUpperCase(); const displayName = displayNameFromDb ?? "Account"; const displayEmail = displayEmailFromDb ?? ""; return (
{avatarUrl ? ( User avatar ) : ( avatarLabel )}
{displayName}
{displayEmail ? (
{displayEmail}
) : null}
setOpen(false)} > Open boards setOpen(false)} > Create board
{( [ { href: "/dashboard", label: "Dashboard", icon: LayoutDashboard }, { href: "/activity", label: "Activity", icon: Activity }, { href: "/agents", label: "Agents", icon: Bot }, { href: "/gateways", label: "Gateways", icon: Server }, { href: "/settings", label: "Settings", icon: Settings }, ] as const ).map((item) => ( setOpen(false)} > {item.label} ))}
); }