From 4607e79b8bffeebe95839890a73858146e09c13f Mon Sep 17 00:00:00 2001 From: Thibault Pouch Date: Fri, 27 Feb 2026 10:22:37 +0100 Subject: [PATCH] feat: implement lazy loading for LoginPage and add Suspense to IntranetLayout --- nest-intra/src/App.tsx | 57 ++++++++++--------- .../src/components/layout/IntranetLayout.tsx | 18 ++++-- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/nest-intra/src/App.tsx b/nest-intra/src/App.tsx index 1a5597c..066dacc 100644 --- a/nest-intra/src/App.tsx +++ b/nest-intra/src/App.tsx @@ -20,35 +20,40 @@ const IntranetModeration = lazy(() => import('./pages/intranet/IntranetModerat export default function App() { return ( - }> - - {/* Login */} - } /> + + {/* Login — own Suspense so the full-page loader only shows here */} + }> + + + } + /> - {/* Intranet (staff only) */} - - - - } - > - } /> - } /> - } /> - } /> - } /> - } /> - + {/* Intranet (staff only) — Suspense is inside IntranetLayout */} + + + + } + > + } /> + } /> + } /> + } /> + } /> + } /> + - {/* Redirect root to intranet */} - } /> + {/* Redirect root to intranet */} + } /> - {/* Catch-all: redirect to intranet */} - } /> - - + {/* Catch-all: redirect to intranet */} + } /> + ); } diff --git a/nest-intra/src/components/layout/IntranetLayout.tsx b/nest-intra/src/components/layout/IntranetLayout.tsx index 52bf4a0..74fa19b 100644 --- a/nest-intra/src/components/layout/IntranetLayout.tsx +++ b/nest-intra/src/components/layout/IntranetLayout.tsx @@ -1,6 +1,6 @@ import { NavLink, Outlet, useNavigate } from 'react-router-dom'; import { useAuth } from '../../contexts/AuthContext'; -import { useCallback } from 'react'; +import { useCallback, Suspense } from 'react'; const INTRANET_LINKS = [ { to: '/intranet', label: 'Dashboard', icon: '[>]', end: true }, @@ -21,7 +21,7 @@ export function IntranetLayout() { }, [logout, navigate]); return ( -
+
{/* Sidebar */} - {/* Main content */} + {/* Main content — only this area scrolls */}
- + +
+ LOADING... +
+
+ } + > + +
);