import { Link, useLocation } from "wouter"; import { LayoutDashboard, Users, Calendar, Settings, FileCheck, Shield, CreditCard, FolderOpen, Database, FileText, Cloud, Phone, Activity, ClipboardList, LayoutGrid, ListChecks, Pill, Microscope, ChevronDown, ChevronRight, } from "lucide-react"; import { cn } from "@/lib/utils"; import { useMemo, useState, useEffect } from "react"; import { useSidebar } from "@/components/ui/sidebar"; import { useAuth } from "@/hooks/use-auth"; type NavChild = { name: string; path: string; icon: React.ReactNode; }; type NavItem = { name: string; path: string; icon: React.ReactNode; adminOnly?: boolean; children?: NavChild[]; }; export function Sidebar() { const [location] = useLocation(); const { state, openMobile, setOpenMobile } = useSidebar(); // "expanded" | "collapsed" const { user } = useAuth(); const isAdmin = user?.username === "admin"; const [expandedPaths, setExpandedPaths] = useState>(() => { const s = new Set(); if (location.startsWith("/chart")) s.add("/chart"); return s; }); useEffect(() => { if (location.startsWith("/chart")) { setExpandedPaths((prev) => new Set([...prev, "/chart"])); } }, [location]); const togglePath = (path: string) => { setExpandedPaths((prev) => { const next = new Set(prev); if (next.has(path)) next.delete(path); else next.add(path); return next; }); }; const navItems: NavItem[] = useMemo( () => [ { name: "Dashboard", path: "/dashboard", icon: , }, { name: "Patient Connection", path: "/patient-connection", icon: , }, { name: "Schedule", path: "/appointments", icon: , }, { name: "Patient Management", path: "/patients", icon: , }, { name: "Chart", path: "/chart", icon: , children: [ { name: "Charting Map", path: "/chart/charting", icon: , }, { name: "Treatment Plan", path: "/chart/treatment-plan", icon: , }, { name: "Prescription", path: "/chart/prescription", icon: , }, { name: "Lab Management", path: "/chart/lab-management", icon: , }, ], }, { name: "Insurance Eligibility", path: "/insurance-status", icon: , }, { name: "Claims/PreAuth", path: "/claims", icon: , }, { name: "Accounts/Payments", path: "/payments", icon: , }, { name: "Documents", path: "/documents", icon: , }, { name: "Reports", path: "/reports", icon: , }, { name: "Cloud storage", path: "/cloud-storage", icon: , }, { name: "Database Management", path: "/database-management", icon: , adminOnly: true, }, { name: "Job Monitor", path: "/job-monitor", icon: , adminOnly: true, }, { name: "Settings", path: "/settings", icon: , adminOnly: true, }, ], [] ); return (
); }