/** * @file components/layout/AppSidebar.tsx * @description Responsive sidebar wrapper for server and channel sidebars with collapsible desktop support. */ "use client"; import { useSidebarStore } from "@/lib/stores/useSidebarStore"; import { ServerSidebar } from "@/components/sidebar/ServerSidebar"; import { ChannelSidebar } from "@/components/sidebar/ChannelSidebar"; import { UserPanel } from "@/components/sidebar/UserPanel"; import { useActiveServer, type ServerWithChannels, } from "@/lib/context/ServerContext"; import type { UserStatus } from "@/db/schema"; import { clsx } from "clsx"; import { DirectMessageSidebar, SidebarConversation, } from "../sidebar/DirectMessageSidebar"; import { usePathname } from "next/navigation"; /** Properties representing the user in the sidebar. */ export interface SidebarUser { username: string; color: string; status: UserStatus; } /** Properties for the AppSidebar component. */ interface AppSidebarProps { servers: ServerWithChannels[]; conversations: SidebarConversation[]; user: SidebarUser; } /**Renders the responsive application sidebar containing server navigation, channel lists, and user profile. */ export function AppSidebar({ servers, user, conversations = [], }: AppSidebarProps) { const { isNavOpen, closeAll } = useSidebarStore(); const { activeServer } = useActiveServer(); const pathname = usePathname(); const isServerRoute = pathname?.startsWith("/servers"); const isDirectMessageView = !isServerRoute && !activeServer; return ( <> {/* 1. DESKTOP VIEW (md:flex) */} {/* 2. MOBILE VIEW (md:hidden) */} {isNavOpen && (
)}
{isDirectMessageView ? ( ) : ( )}
); }