feat(dashboard): use username instead of email for the generation of the

fallback avatar image
This commit is contained in:
2025-07-28 19:20:05 +02:00
parent 30c2c7afb0
commit f8261b5364
3 changed files with 8 additions and 11 deletions

View File

@@ -28,14 +28,11 @@ export function formatTimestamp(timestamp: string | number) {
}
}
export function getFallbackAvatarInitials(email: string | undefined): string {
if (typeof email === "undefined") return "CN";
const [emailUsername = ""] = email.split('@');
const parts = emailUsername.split(/[\._-]+/).filter(Boolean);
if (parts.length >= 2) {
// @ts-ignore we are sure parts[0] and parts[1] exist
return (parts[0]?.charAt(0) + parts[1].charAt(0)).toUpperCase();
export function getFallbackAvatarInitials(fullName: string | undefined): string {
if (typeof fullName === "undefined" || fullName === "") return "CN";
const [ name = "", surname = "" ] = fullName.split(" ");
if (surname === "") {
return (name.substring(0,2)).toUpperCase();
}
return emailUsername.slice(0, 2).toUpperCase();
return (name.charAt(0) + surname.charAt(0)).toUpperCase();
}