"use client"; import { ColorShade, getColorHash } from "#/utils/colors"; import { useTheme } from "next-themes"; interface AvatarProps { name: string | null | undefined; loginName: string; imageUrl?: string; size?: "small" | "base" | "large"; shadow?: boolean; } function getCredentials(name: string, loginName: string) { let credentials = ""; if (name) { const split = name.split(" "); if (split) { const initials = split[0].charAt(0) + (split[1] ? split[1].charAt(0) : ""); credentials = initials; } else { credentials = name.charAt(0); } } else { const username = loginName.split("@")[0]; let separator = "_"; if (username.includes("-")) { separator = "-"; } if (username.includes(".")) { separator = "."; } const split = username.split(separator); const initials = split[0].charAt(0) + (split[1] ? split[1].charAt(0) : ""); credentials = initials; } return credentials; } export function Avatar({ size = "base", name, loginName, imageUrl, shadow, }: AvatarProps) { const { resolvedTheme } = useTheme(); const credentials = getCredentials(name ?? loginName, loginName); const color: ColorShade = getColorHash(loginName); const avatarStyleDark = { backgroundColor: color[900], color: color[200], }; const avatarStyleLight = { backgroundColor: color[200], color: color[900], }; return (