import React from 'react'; import { Avatar as AvatarBase, AvatarFallback, AvatarImage } from './AvatarBase'; import { getFirstTwoCapitalizedLetters } from '@/lib/text'; import { Tooltip } from '../tooltip/Tooltip'; import { BusterLogo } from '@/assets/svg/BusterLogo'; import { cn } from '@/lib/utils'; export interface BusterUserAvatarProps { image?: string; name?: string | null; className?: string; useToolTip?: boolean; } export const Avatar: React.FC = React.memo( ({ image, name, className, useToolTip }) => { const hasName = !!name; const nameLetters = hasName ? createNameLetters(name, image) : ''; return ( {image && } {nameLetters || } ); } ); Avatar.displayName = 'Avatar'; const BusterAvatarFallback: React.FC = () => { return (
); }; const createNameLetters = (name?: string | null, image?: string | null | React.ReactNode) => { if (name && !image) { const firstTwoLetters = getFirstTwoCapitalizedLetters(name); if (firstTwoLetters.length == 2) return firstTwoLetters; //Get First Name Initial const _name = name.split(' ') as [string, string]; const returnName = `${_name[0][0]}`.toUpperCase().replace('@', ''); return returnName; } return ''; };