import React from 'react'; import { Link, useLocation, useNavigate } from 'react-router-dom'; import { Home, Store, BarChart3, HeartPulse, Wrench, ShoppingBag, AlertTriangle, UserCheck, ShieldCheck, LogOut, LayoutGrid } from 'lucide-react'; import { useAuth } from '../context/useAuth'; export function NavigationHeader({ title, subtitle, icon: TitleIcon, health, onResetHome, children, }) { const location = useLocation(); const path = location.pathname; const search = location.search; const navigate = useNavigate(); const { user, role, logout } = useAuth(); const handleLogout = () => { logout(); navigate('/login'); }; const getRoleBadge = () => { if (role === 'admin') { return ( Admin ); } return ( User ); }; return (
{/* Left Section: Home/Back Button + Page Title */}
{ if (onResetHome) onResetHome(); }} title={role === 'admin' ? 'Navigate to Catalog' : 'Navigate to User Workspace'} className="group flex items-center gap-2 rounded-full bg-gradient-to-r from-amber-500 to-amber-600 hover:from-amber-600 hover:to-amber-700 text-white px-4 py-2 text-xs font-semibold shadow-sm transition-all duration-200 active:scale-95 hover:shadow-md" > {role === 'admin' ? 'Home / Catalog' : 'Home / Workspace'} {title && (
{TitleIcon && (
)}

{title}

{subtitle &&

{subtitle}

}
)}
{/* Right Section: System Health + Role-Based Nav Tabs + Logout Button */}
{health && health.status !== 'ok' && ( {!health.database && !health.ollama ? 'DB & Ollama offline' : !health.database ? 'Database offline' : 'Ollama offline'} )} {/* User Role Profile Badge */}
{user?.display_name || user?.username || 'Guest'} {getRoleBadge()}
{/* Role-tailored Navigation Tabs */} {/* Top Right Logout Button */}
{children}
); }