feat(dashboard): generate user fallback avatar using user email. Allow

user to select the default avatar.
This commit is contained in:
Daniele Pintore
2025-07-28 16:17:52 +02:00
parent 17e9154887
commit 30c2c7afb0
3 changed files with 30 additions and 2 deletions
+12
View File
@@ -27,3 +27,15 @@ export function formatTimestamp(timestamp: string | number) {
return "Fecha inválida";
}
}
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();
}
return emailUsername.slice(0, 2).toUpperCase();
}