import { useEffect, useRef } from 'react'; import { Link, useLocation } from 'react-router-dom'; import { X, LogOut } from 'lucide-react'; import { useAuth } from '../../context/AuthContext'; import { usePermissions } from '../../hooks/usePermissions'; import { getFilteredNavSections } from '../../lib/navigation'; import { RoleBadge } from '../ui/RoleBadge'; import ThemeToggle from '../ThemeToggle'; interface MobileNavSheetProps { isOpen: boolean; onClose: () => void; } /** * Mobile slide-up navigation sheet * Linear-inspired: clean, smooth animations */ export function MobileNavSheet({ isOpen, onClose }: MobileNavSheetProps) { const { user, logout } = useAuth(); const { role } = usePermissions(); const location = useLocation(); const sections = getFilteredNavSections(role); const sheetRef = useRef(null); // Close on escape key useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; if (isOpen) { document.addEventListener('keydown', handleEscape); document.body.style.overflow = 'hidden'; } return () => { document.removeEventListener('keydown', handleEscape); document.body.style.overflow = ''; }; }, [isOpen, onClose]); // Close when navigating useEffect(() => { onClose(); }, [location.pathname]); if (!isOpen) return null; return (
{/* Backdrop */}
{/* Sheet */}
{/* Handle */}
{/* Header */}
{user?.email?.[0]?.toUpperCase() || '?'}

{user?.name || user?.email}

{/* Navigation Sections */}
{sections.map(section => (

{section.label}

{section.items.map(item => { const Icon = item.icon; const isActive = location.pathname === item.path; return ( {item.shortLabel || item.label} ); })}
))}
{/* Footer Actions */}
); }