/** * @file components/layout/AppHeader.tsx * @description Application top header component providing navigation controls, dynamic channel or friend tab titles, and optional server settings or member list toggles. */ "use client"; import { useSidebarStore } from "@/lib/stores/useSidebarStore"; import { PanelLeftOpen, PanelLeftClose, Users, Hash } from "lucide-react"; import { ServerSettingsMenu } from "./ServerSettingsMenu"; import { FriendsHeader, TabType } from "@/components/friends/FriendsHeader"; /** * Properties for the AppHeader component. * * @interface AppHeaderProps * @property {string} [title] - The title of the current channel or view. * @property {boolean} [showMembersButton=false] - Whether to show the button that toggles the members sidebar. * @property {{ id: string; name: string }} [server] - Optional server configuration object containing its unique identifier and name. * @property {boolean} [showFriendsTabs=false] - Whether to display the friends navigation tabs in the header. * @property {TabType} [activeTab] - The currently active friends tab identifier. * @property {(tab: TabType) => void} [setActiveTab] - Callback function to update the active friends tab. * @property {number} [allCount=0] - The total number of friends. * @property {number} [pendingCount=0] - The number of pending friend requests. */ interface AppHeaderProps { title?: string; showMembersButton?: boolean; server?: { id: string; name: string; }; showFriendsTabs?: boolean; activeTab?: TabType; setActiveTab?: (tab: TabType) => void; allCount?: number; pendingCount?: number; } /** * Renders the application header with navigation controls, dynamic titles, tabs, and action buttons. * * @param {AppHeaderProps} props - The component props. * @param {string} [props.title] - The title of the current channel or view. * @param {boolean} [props.showMembersButton=false] - Whether to show the members list toggle button. * @param {{ id: string; name: string }} [props.server] - Optional server details object. * @param {boolean} [props.showFriendsTabs=false] - Whether to display the friends tabs. * @param {TabType} [props.activeTab] - The active friends tab. * @param {(tab: TabType) => void} [props.setActiveTab] - Function to change the active friends tab. * @param {number} [props.allCount=0] - Count of all friends. * @param {number} [props.pendingCount=0] - Count of pending friend requests. * @returns {JSX.Element} The rendered application header container. */ export function AppHeader({ title, showMembersButton = false, server, showFriendsTabs = false, activeTab, setActiveTab, allCount = 0, pendingCount = 0, }: AppHeaderProps) { const { isNavOpen, toggleNav, toggleMembers } = useSidebarStore(); const hasContent = !isNavOpen || !!title || showMembersButton || !!server || showFriendsTabs; return (