import { useEffect, useMemo, useState } from 'react' import { profileRepository } from '../repositories/profileRepository.js' import { BrandLogo } from './Brand.jsx' import { FeatureLegend } from './FeatureState.jsx' const navItems = [ { href: '/inicio', label: 'Painel', icon: 'pulse', activePaths: ['/inicio', '/home', '/dashboard'] }, { href: '/agenda', label: 'Agenda', icon: 'calendar' }, { href: '/pacientes', label: 'Pacientes', icon: 'users', exact: true }, { href: '/prontuario', label: 'Prontuario', icon: 'file' }, { href: '/laudos', label: 'Laudos', icon: 'clipboard' }, { href: '/camunicacao', label: 'Comunicacao', icon: 'message', activePaths: ['/camunicacao', '/comunicacao', '/mensagens'], }, { href: '/relatorios', label: 'Relatorios', icon: 'chart' }, { href: '/configuracoes', label: 'Configuracoes', icon: 'settings', activePaths: ['/configuracoes', '/config'] }, ] const titles = { '/inicio': 'Painel', '/home': 'Painel', '/dashboard': 'Painel', '/agenda': 'Agenda', '/consultas': 'Consultas', '/laudos': 'Laudos', '/pacientes': 'Pacientes', '/prontuario': 'Prontuario', '/camunicacao': 'Comunicacao', '/comunicacao': 'Comunicacao', '/mensagens': 'Comunicacao', '/relatorios': 'Relatorios', '/profissionais': 'Profissionais', '/perfil': 'Perfil', '/configuracoes': 'Configuracoes', '/config': 'Configuracoes', } export function AppShell({ children, currentPath, navigate, routeTitle }) { const [menuOpen, setMenuOpen] = useState(false) const [quickSearch, setQuickSearch] = useState('') const [viewerProfile, setViewerProfile] = useState({ name: 'Usuario', role: 'Usuario do Sistema' }) const pageTitle = useMemo(() => { if (currentPath.startsWith('/pacientes/') && routeTitle) { return routeTitle } return routeTitle || titles[currentPath] || 'MediConnect' }, [currentPath, routeTitle]) useEffect(() => { let active = true profileRepository.getCurrentUserProfile() .then((profile) => { if (!active || !profile) return setViewerProfile({ name: profile.name || 'Usuario', role: profile.role || 'Usuario do Sistema', }) }) .catch(() => {}) return () => { active = false } }, []) function goTo(path) { setMenuOpen(false) navigate(path) } return (
Pular para conteudo {menuOpen ? (
setQuickSearch(event.target.value)} placeholder="Buscar paciente, prontuario..." value={quickSearch} />
{quickSearch ? (
Busca local ativa por {quickSearch}.
) : null}
{pageTitle}
{children}
) } function NavItem({ active, item, onNavigate }) { return ( { event.preventDefault() onNavigate(item.href) }} > {item.label} ) } function isActive(pathname, item) { if (item.activePaths?.some((path) => pathname === path || pathname.startsWith(`${path}/`))) { return true } if (item.activePrefixes?.some((path) => pathname.startsWith(path))) { return true } if (item.exact) { return pathname === item.href } return pathname === item.href || pathname.startsWith(`${item.href}/`) } function AppIcon({ className = 'size-5', name }) { const common = { className, fill: 'none', stroke: 'currentColor', strokeLinecap: 'round', strokeLinejoin: 'round', strokeWidth: 1.8, viewBox: '0 0 24 24', } if (name === 'calendar') { return ( ) } if (name === 'users') { return ( ) } if (name === 'file') { return ( ) } if (name === 'clipboard') { return ( ) } if (name === 'message') { return ( ) } if (name === 'chart') { return ( ) } if (name === 'dollar') { return ( ) } if (name === 'settings') { return ( ) } return ( ) } function BellIcon({ className = 'size-5' }) { return ( ) } function ChevronDownIcon({ className = 'size-4' }) { return ( ) } function SearchIcon({ className = 'size-4' }) { return ( ) } function getInitials(name) { return String(name || 'US') .split(' ') .filter(Boolean) .slice(0, 2) .map((part) => part[0]) .join('') .toUpperCase() }