import * as AvatarPrimitive from "@radix-ui/react-avatar"; import React from "react"; import { getTailwindColor } from "./color-utils"; import { cn } from "../../lib/utils"; const Avatar = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); Avatar.displayName = AvatarPrimitive.Root.displayName; const AvatarImage = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); AvatarImage.displayName = AvatarPrimitive.Image.displayName; const AvatarFallback = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; // Function to get the first two letters export const getInitials = (name: string, noOfChar?: number | undefined) => { if (!name) { return ""; } const words = name.split(" "); return words .map((word) => word.charAt(0)) .filter((char) => char !== "") .slice(0, noOfChar ? noOfChar : 1) .join("") .toUpperCase(); }; const AvatarText = ({ text, className, noOfChar, }: { text: string; className?: string; noOfChar?: number; }) => { return ( {getInitials(text, noOfChar)} ); }; export { Avatar, AvatarImage, AvatarFallback, AvatarText };