/** * @file UserBadge.tsx * @description Server component rendering the authenticated user profile badge with initials and name. */ import { auth } from "@/auth"; import { UserService } from "@/services/user.service"; import { getInitials } from "@/utils/user"; /** * Renders a user profile badge including an avatar initial circle with user color and full name. * * @async * @returns {Promise} The rendered user badge component, or null if unauthenticated. */ export default async function UserBadge() { const session = await auth(); if (!session?.user?.id) return null; const user = await UserService.findProfileById(session.user.id); if (!user) return null; const fullName = `${user.firstName} ${user.lastName}`.trim(); const initials = getInitials(user.firstName, user.lastName); const bgColor = user.color || "bg-primary"; return (
{initials}

{fullName}

Online

); }