/** * @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 { clsx } from "clsx"; import { DirectMessageSidebar, SidebarConversation, } from "../sidebar/DirectMessageSidebar"; import { usePathname } from "next/navigation"; /** Properties for the AppSidebar component. */ interface AppSidebarProps { servers: ServerWithChannels[]; conversations: SidebarConversation[]; } /** Renders the responsive application sidebar containing server navigation, channel lists, and user profile. */ export function AppSidebar({ servers, 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 ? ( ) : ( )}
); }