mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-05 05:55:21 +02:00
feat(dashboard): use username instead of email for the generation of the
fallback avatar image
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user