"use client"; import { BoxesIcon, LogOutIcon, MonitorIcon, MoonIcon, SunIcon, TagIcon, TagsIcon } from "lucide-react"; import Link from "next/link"; import { useTheme } from "next-themes"; import { useTransition } from "react"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; export type MenuUser = { name: string | null; email: string | null; image: string | null }; function initials(user: MenuUser): string { const source = user.name || user.email || "?"; const parts = source.split(/[\s@._-]+/).filter(Boolean); return ((parts[0]?.[0] ?? "?") + (parts.length > 1 ? parts[1][0] : "")).toUpperCase(); } function UserAvatar({ user, size }: { user: MenuUser; size?: "sm" | "default" | "lg" }) { return ( {user.image && } {initials(user)} ); } /** Avatar from the OIDC profile; opens a menu with account info, settings, theme and sign out. */ export function UserMenu({ user, signOutAction }: { user: MenuUser; signOutAction: () => Promise }) { const { theme, setTheme } = useTheme(); const [signingOut, startSignOut] = useTransition(); return ( {user.name ?? user.email} {user.name ?? "Signed in"} {user.email && {user.email}} Settings }> File labels }> Tags }> Runtimes Theme setTheme(v as string)}> System Light Dark startSignOut(() => signOutAction())}> {signingOut ? "Signing out…" : "Sign out"} ); }