diff --git a/apps/dokploy/components/dashboard/settings/profile/profile-form.tsx b/apps/dokploy/components/dashboard/settings/profile/profile-form.tsx index 49fdfd2dd..89014601e 100644 --- a/apps/dokploy/components/dashboard/settings/profile/profile-form.tsx +++ b/apps/dokploy/components/dashboard/settings/profile/profile-form.tsx @@ -1,3 +1,4 @@ +import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { AlertBlock } from "@/components/shared/alert-block"; import { Button } from "@/components/ui/button"; import { @@ -19,7 +20,7 @@ import { import { Input } from "@/components/ui/input"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Switch } from "@/components/ui/switch"; -import { generateSHA256Hash } from "@/lib/utils"; +import { generateSHA256Hash, getFallbackAvatarInitials } from "@/lib/utils"; import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; import { Loader2, User } from "lucide-react"; @@ -257,6 +258,24 @@ export const ProfileForm = () => { value={field.value} className="flex flex-row flex-wrap gap-2 max-xl:justify-center" > + + + + + + + + + {getFallbackAvatarInitials( + data?.user?.name, + )} + + + + {availableAvatars.map((image) => ( diff --git a/apps/dokploy/components/layouts/user-nav.tsx b/apps/dokploy/components/layouts/user-nav.tsx index ff48b62d9..e476a5f50 100644 --- a/apps/dokploy/components/layouts/user-nav.tsx +++ b/apps/dokploy/components/layouts/user-nav.tsx @@ -19,6 +19,7 @@ import { } from "@/components/ui/select"; import { authClient } from "@/lib/auth-client"; import { Languages } from "@/lib/languages"; +import { getFallbackAvatarInitials } from "@/lib/utils"; import { api } from "@/utils/api"; import useLocale from "@/utils/hooks/use-locale"; import { ModeToggle } from "../ui/modeToggle"; @@ -46,7 +47,9 @@ export const UserNav = () => { src={data?.user?.image || ""} alt={data?.user?.image || ""} /> - CN + + {getFallbackAvatarInitials(data?.user?.name)} +
Account diff --git a/apps/dokploy/lib/utils.ts b/apps/dokploy/lib/utils.ts index b763e9ee9..f01faa4ec 100644 --- a/apps/dokploy/lib/utils.ts +++ b/apps/dokploy/lib/utils.ts @@ -27,3 +27,14 @@ export function formatTimestamp(timestamp: string | number) { return "Fecha inválida"; } } + +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 (name.charAt(0) + surname.charAt(0)).toUpperCase(); +}