/**
* @file components/sidebar/ChannelSidebar.tsx
* @description Sidebar component displaying server channels, navigation toggles, and modal triggers.
*/
"use client";
import { useState } from "react";
import Link from "next/link";
import { useParams } from "next/navigation";
import { useActiveServer } from "@/lib/context/ServerContext";
import { DirectMessageSidebar } from "@/components/sidebar/DirectMessageSidebar";
import { useSidebarStore } from "@/lib/stores/useSidebarStore";
import { CreateChannelModal } from "@/components/modals/CreateChannelModal";
import { PanelLeftClose, Plus } from "lucide-react";
/**
* Renders the channel sidebar for active servers, allowing users to navigate channels or create new ones.
*
* @returns {JSX.Element} The rendered channel sidebar container.
*/
export function ChannelSidebar() {
const [isModalOpen, setIsModalOpen] = useState(false);
const params = useParams();
const currentChannelId = params?.channelId as string;
const { activeServer } = useActiveServer();
const { closeNav, toggleNav } = useSidebarStore();
/**
* Handles channel selection clicks, closing the mobile navigation sidebar on smaller viewports.
*
* @function handleChannelClick
* @returns {void}
*/
const handleChannelClick = () => {
if (!window.matchMedia("(min-width: 768px)").matches) {
closeNav();
}
};
if (!activeServer) {
return