"use client"; import React from "react"; // No hooks needed since state is now managed by parent import Link from "next/link"; import Image from "next/image"; import { usePathname } from "next/navigation"; import { signOut } from "next-auth/react"; import { SimpleThemeToggle } from "@/components/ui/theme-toggle"; // Icons for the sidebar const DashboardIcon = () => ( ); const CompanyIcon = () => ( ); const UsersIcon = () => ( ); const SessionsIcon = () => ( ); const LogoutIcon = () => ( ); const MinimalToggleIcon = ({ isExpanded }: { isExpanded: boolean }) => ( {isExpanded ? ( ) : ( )} ); export interface SidebarProps { isExpanded: boolean; onToggle: () => void; isMobile?: boolean; // Add this property to indicate mobile viewport onNavigate?: () => void; // Function to call when navigating to a new page } interface NavItemProps { href: string; label: string; icon: React.ReactNode; isExpanded: boolean; isActive: boolean; onNavigate?: () => void; // Function to call when navigating to a new page } const NavItem: React.FC = ({ href, label, icon, isExpanded, isActive, onNavigate, }) => ( { if (onNavigate) { onNavigate(); } }} > {icon} {isExpanded ? ( {label} ) : (
{label}
)} ); export default function Sidebar({ isExpanded, onToggle, isMobile = false, onNavigate, }: SidebarProps) { const pathname = usePathname() || ""; const handleLogout = () => { signOut({ callbackUrl: "/login" }); }; return ( <> {/* Backdrop overlay when sidebar is expanded on mobile */} {isExpanded && isMobile && (
)}
{/* Toggle button when sidebar is collapsed - above logo */} {!isExpanded && (
)} {/* Logo section with link to homepage */}
LiveDash Logo
{isExpanded && ( LiveDash )}
{isExpanded && (
)}
{/* Theme Toggle */}
{isExpanded && Theme}
{/* Logout Button */}
); }