/** * router.tsx * Rotas da aplicação com proteção por autenticação. */ import { createBrowserRouter, Navigate } from 'react-router-dom'; import { lazy, Suspense } from 'react'; import AppLayout from '@/components/layout/AppLayout'; import PageLoader from '@/components/ui/PageLoader'; import { ProtectedRoute } from '@/components/auth/ProtectedRoute'; // ─── Lazy pages ─────────────────────────────────────────────────────────────── const LoginPage = lazy(() => import('@/pages/LoginPage')); const DashboardPage = lazy(() => import('@/pages/DashboardPage')); const NewTicketPage = lazy(() => import('@/pages/NewTicketPage')); const TicketDetailPage = lazy(() => import('@/pages/TicketDetailPage')); const UsersPage = lazy(() => import('@/pages/UsersPage')); const SettingsPage = lazy(() => import('@/pages/SettingsPage')); function Lazy({ children }: { children: React.ReactNode }) { return }>{children}; } // ─── Router ─────────────────────────────────────────────────────────────────── export const router = createBrowserRouter([ // ── Rota pública: login (sem AppLayout) ─────────────────────────────────── { path: '/login', element: , }, // ── Rotas protegidas (requerem autenticação) ────────────────────────────── { path: '/', element: ( ), children: [ { index: true, element: , }, { path: 'dashboard', element: , }, { path: 'tickets/new', element: , }, { path: 'tickets/:id', element: , }, { path: 'users', element: , }, { path: 'settings', element: , }, ], }, // Fallback { path: '*', element: }, ]);