diff --git a/components/user-menu.tsx b/components/user-menu.tsx index c74378e..b295daa 100644 --- a/components/user-menu.tsx +++ b/components/user-menu.tsx @@ -18,6 +18,11 @@ export interface UserMenuProps { user: Session['user'] } +function getUserInitials(name: string) { + const [firstName, lastName] = name.split(' ') + return lastName ? `${firstName[0]}${lastName[0]}` : firstName.slice(0, 2) +} + export function UserMenu({ user }: UserMenuProps) { return (
@@ -32,7 +37,7 @@ export function UserMenu({ user }: UserMenuProps) { /> ) : (
- {user?.name ? user?.name.slice(0, 2) : null} + {user?.name ? getUserInitials(user?.name) : null}
)} {user?.name}