aboutsummaryrefslogtreecommitdiff
path: root/web/src/router.tsx
diff options
context:
space:
mode:
authorzwlucas <lucas.fariamo08@gmail.com>2026-07-25 21:23:29 +0000
committerzwlucas <lucas.fariamo08@gmail.com>2026-07-25 21:23:29 +0000
commitef55d9bb24430610b60c1b77821307cd72c08c55 (patch)
treee6935a810b34370b0a4c821e55f6397aac50c832 /web/src/router.tsx
downloadhelpdesk-master.tar.gz
helpdesk-master.zip
feat: upload of the projectHEADmaster
Signed-off-by: zwlucas <lucas.fariamo08@gmail.com>
Diffstat (limited to 'web/src/router.tsx')
-rw-r--r--web/src/router.tsx70
1 files changed, 70 insertions, 0 deletions
diff --git a/web/src/router.tsx b/web/src/router.tsx
new file mode 100644
index 0000000..5105fec
--- /dev/null
+++ b/web/src/router.tsx
@@ -0,0 +1,70 @@
+/**
+ * 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 <Suspense fallback={<PageLoader />}>{children}</Suspense>;
+}
+
+// ─── Router ───────────────────────────────────────────────────────────────────
+export const router = createBrowserRouter([
+ // ── Rota pública: login (sem AppLayout) ───────────────────────────────────
+ {
+ path: '/login',
+ element: <Lazy><LoginPage /></Lazy>,
+ },
+
+ // ── Rotas protegidas (requerem autenticação) ──────────────────────────────
+ {
+ path: '/',
+ element: (
+ <ProtectedRoute>
+ <AppLayout />
+ </ProtectedRoute>
+ ),
+ children: [
+ {
+ index: true,
+ element: <Navigate to="/dashboard" replace />,
+ },
+ {
+ path: 'dashboard',
+ element: <Lazy><DashboardPage /></Lazy>,
+ },
+ {
+ path: 'tickets/new',
+ element: <Lazy><NewTicketPage /></Lazy>,
+ },
+ {
+ path: 'tickets/:id',
+ element: <Lazy><TicketDetailPage /></Lazy>,
+ },
+ {
+ path: 'users',
+ element: <Lazy><UsersPage /></Lazy>,
+ },
+ {
+ path: 'settings',
+ element: <Lazy><SettingsPage /></Lazy>,
+ },
+ ],
+ },
+
+ // Fallback
+ { path: '*', element: <Navigate to="/dashboard" replace /> },
+]);