mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-09 05:25:18 +00:00
feat(dashboard): generate user fallback avatar using user email. Allow
user to select the default avatar.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user