diff --git a/apps/spu-ui/src/app/_components/user-avatar.tsx b/apps/spu-ui/src/app/_components/user-avatar.tsx index 7b93eea..fd48061 100644 --- a/apps/spu-ui/src/app/_components/user-avatar.tsx +++ b/apps/spu-ui/src/app/_components/user-avatar.tsx @@ -3,9 +3,27 @@ import { redirect } from "next/navigation"; import { LogOutIcon, UserIcon } from "lucide-react"; import { auth, signOut } from "@sophys-web/auth"; import { Button, buttonVariants } from "@sophys-web/ui/button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@sophys-web/ui/dropdown-menu"; + +function getInitials(name: string): string { + return name + .split(/[ .]+/) // Split by spaces or dots + .filter(Boolean) // Remove empty strings + .map((part) => part[0]?.toUpperCase()) // Take the first letter and convert to uppercase + .join(""); // Combine into a single string +} export default async function UserAvatar() { const session = await auth(); + const initials = getInitials(session?.user.name ?? "unknown"); + if (!session) { return ( @@ -13,23 +31,63 @@ export default async function UserAvatar() { ); } + return ( -
- - {session.user.name} -
{ - "use server"; - await signOut({ - redirect: false, - }); - redirect("/"); - }} - > - -
-
+ + + +
+ +
+ + {session.user.name} + + + {session.user.roles?.join(", ")} + +
+
+
+ + + + +
+ + ); +} + +function SignOut() { + return ( +
{ + "use server"; + await signOut({ + redirect: false, + }); + redirect("/"); + }} + > + +
); }