/** * AppLayout.tsx * * Shell principal da aplicação: sidebar + header + área de conteúdo. * Todas as páginas são renderizadas dentro deste layout via . */ import { NavLink, Outlet, useLocation, useNavigate } from 'react-router-dom'; import { useAuth } from '@/context/AuthContext'; import { useTicketEvents } from '@/hooks/useTicketEvents'; import styles from './AppLayout.module.css'; // ─── Ícones inline (SVG) ────────────────────────────────────────────────────── const Icons = { Dashboard: () => ( ), Plus: () => ( ), Ticket: () => ( ), Logo: () => ( ), User: () => ( ), Users: () => ( ), Settings: () => ( ), }; // ─── Mapa de títulos por rota ───────────────────────────────────────────────── const ROUTE_TITLES: Record = { '/dashboard': 'Dashboard', '/tickets/new': 'Abrir Chamado', '/users': 'Usuários', }; function getPageTitle(pathname: string): string { if (ROUTE_TITLES[pathname]) return ROUTE_TITLES[pathname]; if (pathname.startsWith('/tickets/')) return 'Detalhe do Chamado'; return 'Helpdesk TI'; } // ─── Componente ─────────────────────────────────────────────────────────────── export default function AppLayout() { const location = useLocation(); const navigate = useNavigate(); const { user, logout } = useAuth(); const pageTitle = getPageTitle(location.pathname); // Inicializa o listener de eventos em tempo real useTicketEvents(); function handleLogout() { logout(); navigate('/login', { replace: true }); } return (
{/* ── Sidebar ─────────────────────────────────────────────────────── */} {/* ── Área principal ───────────────────────────────────────────────── */}
{/* Header */}

{pageTitle}

Novo Chamado
{/* Conteúdo da página */}
); }