/** * @file components/sidebar/DirectMessageSidebar.tsx * @description Sidebar listing direct messages and friends list when no server is selected. */ "use client"; import { useSidebarStore } from "@/lib/stores/useSidebarStore"; import { PanelLeftClose, Users } from "lucide-react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { clsx } from "clsx"; import { UserAvatar } from "@/components/ui/UserAvatar"; import { FriendUser } from "../friends/FriendsView"; /** * Represents a direct message conversation in the sidebar. * * @interface SidebarConversation * @property {string} id - The unique identifier of the conversation. * @property {FriendUser} partner - The other user participating in the conversation. */ export interface SidebarConversation { id: string; partner: FriendUser; } /** * Properties for the DirectMessageSidebar component. * * @interface DirectMessageSidebarProps * @property {SidebarConversation[]} [conversations=[]] - Array of active direct message conversations. */ interface DirectMessageSidebarProps { conversations?: SidebarConversation[]; } /** * Renders the direct message sidebar with navigation options, friends view link, and a list of active DM chats. * * @param {DirectMessageSidebarProps} props - The component props. * @param {SidebarConversation[]} [props.conversations=[]] - Array of active direct message conversations. * @returns {JSX.Element} The rendered direct message sidebar. */ export function DirectMessageSidebar({ conversations = [], }: DirectMessageSidebarProps) { const { toggleNav } = useSidebarStore(); const pathname = usePathname(); return (
{/* Header */}
Direct Messages
{/* Navigation & List */}
Friends
All Messages
{conversations.length === 0 ? (
No active chats
) : (
{conversations.map((c) => { const isActive = pathname === `/dm/${c.id}`; return ( {/* UserAvatar Integration */} {c.partner.username} ); })}
)}
); }