"use client"; import { useState } from "react"; import Link from "next/link"; import Image from "next/image"; import { usePathname } from "next/navigation"; import { signOut } from "next-auth/react"; // Icons for the sidebar const DashboardIcon = () => ( ); const CompanyIcon = () => ( ); const UsersIcon = () => ( ); const SessionsIcon = () => ( ); const LogoutIcon = () => ( ); const ToggleIcon = ({ isExpanded }: { isExpanded: boolean }) => ( ); interface NavItemProps { href: string; label: string; icon: React.ReactNode; isExpanded: boolean; isActive: boolean; } const NavItem: React.FC = ({ href, label, icon, isExpanded, isActive, }) => ( {icon} {isExpanded ? ( {label} ) : ( {label} )} ); export default function Sidebar() { const [isExpanded, setIsExpanded] = useState(true); const pathname = usePathname() || ""; const toggleSidebar = () => { setIsExpanded(!isExpanded); }; const handleLogout = () => { signOut({ callbackUrl: "/login" }); }; return ( {/* Logo section - now above toggle button */} {isExpanded && ( LiveDash )} {/* Toggle button */} {!isExpanded && ( {isExpanded ? "Collapse sidebar" : "Expand sidebar"} )} {/* Navigation items */} } isExpanded={isExpanded} isActive={pathname === "/dashboard"} /> } isExpanded={isExpanded} isActive={pathname === "/dashboard/overview"} /> } isExpanded={isExpanded} isActive={pathname.startsWith("/dashboard/sessions")} /> } isExpanded={isExpanded} isActive={pathname === "/dashboard/company"} /> } isExpanded={isExpanded} isActive={pathname === "/dashboard/users"} /> {/* Logout at the bottom */} {isExpanded ? ( Logout ) : ( Logout )} ); }