diff --git a/auth.ts b/auth.ts
index 6dec7fe..ef5e3f3 100644
--- a/auth.ts
+++ b/auth.ts
@@ -51,9 +51,10 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
return {
id: user.id,
- name: user.username,
+ username: user.username,
email: user.email,
color: user.color,
+ status: user.status,
};
},
}),
@@ -70,7 +71,9 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
jwt({ token, user }) {
if (user) {
token.id = user.id;
+ token.username = user.username;
token.color = user.color;
+ token.status = user.status;
}
return token;
},
@@ -85,7 +88,9 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
session({ session, token }) {
if (token && session.user) {
session.user.id = token.id as string;
+ session.user.username = token.username as string;
session.user.color = token.color as string;
+ session.user.status = token.status as any;
}
return session;
},
diff --git a/components/chat/ChatItem.tsx b/components/chat/ChatItem.tsx
index 676b98a..6a04350 100644
--- a/components/chat/ChatItem.tsx
+++ b/components/chat/ChatItem.tsx
@@ -6,6 +6,7 @@
"use client";
import type { Message, Member, User } from "@/db/schema";
+import { UserAvatar } from "../ui/UserAvatar";
/**
* Composite message type extending base database Message with populated member and user relation.
@@ -26,7 +27,6 @@ export type MessageWithMember = Message & {
export function ChatItem({ message }: { message: MessageWithMember }) {
const user = message.member?.user;
const fullName = user ? user.username.trim() : "Deleted Member";
- const initial = user?.username?.charAt(0) || "?";
const formattedTime = new Date(message.createdAt).toLocaleTimeString(
"de-DE",
@@ -38,14 +38,8 @@ export function ChatItem({ message }: { message: MessageWithMember }) {
return (
- {/* Avatar */}
-
- {initial}
-
+ {/* Avatar Component */}
+
{/* Message Header & Content */}
diff --git a/components/members/MemberItem.tsx b/components/members/MemberItem.tsx
index 0729b73..4b66387 100644
--- a/components/members/MemberItem.tsx
+++ b/components/members/MemberItem.tsx
@@ -4,11 +4,8 @@
*/
import type { UserStatus } from "@/db/schema";
-import {
- MEMBER_COLOR_CLASSES,
- MEMBER_STATUS_COLOR_CLASSES,
-} from "@/lib/constants/member.styles";
import { clsx } from "clsx";
+import { UserAvatar } from "../ui/UserAvatar";
/**
* Interface representing a member user.
@@ -45,9 +42,6 @@ interface MemberItemProps {
* @returns {JSX.Element} The rendered member item.
*/
export function MemberItem({ member, isOffline = false }: MemberItemProps) {
- const userBg = member.color && MEMBER_COLOR_CLASSES[member.color];
- const statusBg = MEMBER_STATUS_COLOR_CLASSES[member.status];
-
return (
-
- {member.username ? member.username.charAt(0).toUpperCase() : "?"}
-
-
+
- {member.username || "Unbekannt"}
+ {member.username}
);
diff --git a/components/sidebar/UserPanel.tsx b/components/sidebar/UserPanel.tsx
index 2feea3b..d2da64b 100644
--- a/components/sidebar/UserPanel.tsx
+++ b/components/sidebar/UserPanel.tsx
@@ -7,48 +7,38 @@
import { LogOut, Settings } from "lucide-react";
import { signOut, useSession } from "next-auth/react";
+import { UserAvatar } from "@/components/ui/UserAvatar";
-/**
- * Renders the user panel footer component showing current session profile details and authentication controls.
- *
- * @returns {JSX.Element} The rendered user panel component.
- */
export function UserPanel() {
const { data: session } = useSession();
- /**
- * Triggers the NextAuth sign-out procedure and redirects the user to the login page.
- */
- const handleLogout = () => {
- signOut({ callbackUrl: "/login" });
- };
+ if (!session?.user) return null;
- const username = session?.user?.name || "User";
- const userInitial = username.charAt(0).toUpperCase();
+ const { user } = session;
return (