/** * @file app/components/layout/UserBadge.tsx * @description Server component rendering the authenticated user profile badge with initials, name, and online status. */ import { auth } from "@/auth"; import { UserService } from "@/lib/services/user.service"; import { getInitials } from "@/lib/utils/user"; /** * Renders a user profile badge including an avatar initial circle with user color, full name, and online status indicator. * * @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; const lastLogin = user.lastLogin; const formattedLastLogin = new Date(lastLogin!).toLocaleString("de-DE", { day: "2-digit", month: "2-digit", year: "numeric", hour: "2-digit", minute: "2-digit", }); return (
{initials}

{fullName}

Online

); }