"use client"; import React, { useState, useEffect } from 'react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { Users, Settings, LogOut, Menu, X, ChevronLeft, ChevronRight, FileText, HelpCircle, LayoutDashboard, User, ClipboardList, Stethoscope, Calendar, FileBarChart } from 'lucide-react'; interface NavigationItem { id: string; name: string; icon: React.ComponentType<{ className?: string }>; href: string; badge?: string; } interface EPDSidebarProps { className?: string; userEmail?: string; userName?: string; } // LEVEL 1: Behandelaar Context Navigation const level1NavigationItems: NavigationItem[] = [ { id: "dashboard", name: "Dashboard", icon: LayoutDashboard, href: "/epd/dashboard" }, { id: "clients", name: "Cliënten", icon: Users, href: "/epd/patients" }, { id: "agenda", name: "Agenda", icon: FileText, href: "/epd/agenda" }, { id: "reports", name: "Rapportage", icon: Settings, href: "/epd/reports" }, ]; // LEVEL 2: Client Dossier Context Navigation (clientId gets injected) const level2NavigationItems: NavigationItem[] = [ { id: "dashboard", name: "Dashboard", icon: LayoutDashboard, href: "" }, { id: "basisgegevens", name: "Basisgegevens", icon: User, href: "/basisgegevens" }, { id: "screening", name: "Screening", icon: ClipboardList, href: "/screening" }, { id: "intake", name: "Intake", icon: FileText, href: "/intakes" }, { id: "diagnose", name: "Diagnose", icon: Stethoscope, href: "/diagnose" }, { id: "behandelplan", name: "Behandelplan", icon: Calendar, href: "/behandelplan" }, { id: "rapportage", name: "Rapportage", icon: FileBarChart, href: "/rapportage" }, ]; export function EPDSidebar({ className = "", userEmail, userName }: EPDSidebarProps) { const pathname = usePathname(); const [isOpen, setIsOpen] = useState(false); const [isCollapsed, setIsCollapsed] = useState(false); // Context detection: Level 2 if URL contains /patients/[id] const isPatientContext = pathname.match(/\/epd\/patients\/[^\/]+/); const patientId = isPatientContext ? pathname.split('/')[3] : null; // Determine which navigation items to show const navigationItems = isPatientContext ? level2NavigationItems.map(item => ({ ...item, href: `/epd/patients/${patientId}${item.href}` })) : level1NavigationItems; // Auto-open sidebar on desktop useEffect(() => { const handleResize = () => { if (window.innerWidth >= 768) { setIsOpen(true); } else { setIsOpen(false); } }; handleResize(); window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); const toggleSidebar = () => setIsOpen(!isOpen); const toggleCollapse = () => setIsCollapsed(!isCollapsed); const handleItemClick = () => { if (window.innerWidth < 768) { setIsOpen(false); } }; // Get user initials const userInitials = userName ? userName.split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2) : userEmail?.slice(0, 2).toUpperCase() || 'EP'; return ( <> {/* Mobile hamburger button */} {/* Mobile overlay */} {isOpen && (
)} {/* Sidebar */}
{/* Header with logo and collapse button */}
{!isCollapsed && (
AI
Mini-EPD Prototype
)} {isCollapsed && ( AI )} {/* Desktop collapse button */}
{/* Navigation */} {/* Bottom section with profile and logout */}
{/* Profile Section */}
{!isCollapsed ? (
{userInitials}

{userName || userEmail || 'Demo User'}

{userEmail || 'demo@mini-epd.demo'}

) : (
{userInitials}
)}
{/* Logout Button */}
); }