/** * @file components/sidebar/CategorySection.tsx * @description Sub-component for rendering a category group and its list of channels. */ "use client"; import { useState } from "react"; import { ChevronDown, ChevronRight, Plus, Settings } from "lucide-react"; import { ChannelItem } from "./ChannelItem"; import type { Channel } from "@/db/schema"; /** Props for the CategorySection component. */ interface CategorySectionProps { title: string; channels: Channel[]; currentChannelId: string; serverId: string; onCloseNav: () => void; onCreateChannel: () => void; onEditChannel: (channel: Channel) => void; onEditCategory?: () => void; } /** Renders a collapsible category section containing channels and contextual actions. */ export function CategorySection({ title, channels, currentChannelId, serverId, onCloseNav, onCreateChannel, onEditChannel, onEditCategory, }: CategorySectionProps) { const [isCollapsed, setIsCollapsed] = useState(false); /** Handles closing mobile navigation when clicking a channel. */ const handleChannelClick = () => { if (!window.matchMedia("(min-width: 768px)").matches) { onCloseNav(); } }; /** Opens settings for a specific channel. */ const handleOpenChannelSettings = (e: React.MouseEvent, channel: Channel) => { e.preventDefault(); e.stopPropagation(); onEditChannel(channel); }; /** Opens settings for the current category. */ const handleOpenCategorySettings = (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); onEditCategory?.(); }; return (