feat: add avatar email fallback

This commit is contained in:
David Nguyen
2023-09-11 16:58:41 +10:00
parent 975d52a07e
commit fbf32404a6
6 changed files with 20 additions and 17 deletions

View File

@ -15,6 +15,7 @@ import {
import { signOut } from 'next-auth/react';
import { useTheme } from 'next-themes';
import { initials } from '@documenso/lib/client-only/recipient-initials';
import { User } from '@documenso/prisma/client';
import { Avatar, AvatarFallback } from '@documenso/ui/primitives/avatar';
import { Button } from '@documenso/ui/primitives/button';
@ -40,19 +41,14 @@ export const ProfileDropdown = ({ user }: ProfileDropdownProps) => {
const isBillingEnabled = getFlag('app_billing');
const initials =
user.name
?.split(' ')
.map((name: string) => name.slice(0, 1).toUpperCase())
.slice(0, 2)
.join('') ?? 'UK';
const avatarFallback = user.name ? initials(user.name) : user.email.slice(0, 1).toUpperCase();
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="relative h-10 w-10 rounded-full">
<Avatar className="h-10 w-10">
<AvatarFallback>{initials}</AvatarFallback>
<AvatarFallback>{avatarFallback}</AvatarFallback>
</Avatar>
</Button>
</DropdownMenuTrigger>