From c518942d3b268ff063f90c2f768b2c82754b09f6 Mon Sep 17 00:00:00 2001 From: KelvinTegelaar Date: Fri, 12 Apr 2024 15:17:38 +0200 Subject: [PATCH] fixes annoying thing --- src/App.jsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 6ac916315a5d..5e5678b80784 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -10,9 +10,15 @@ TimeAgo.addDefaultLocale(en) import { library } from '@fortawesome/fontawesome-svg-core' import { fas } from '@fortawesome/free-solid-svg-icons' import routes from 'src/routes' +import { useAuthCheck } from './components/utilities/CippauthCheck' +import importsMap from './importsMap' + library.add(fas) -const dynamicImport = (path) => React.lazy(() => import(`./${path}`)) +const dynamicImport = (path) => { + return importsMap[path] || null +} + const DefaultLayout = React.lazy(() => import('./layout/DefaultLayout')) const Page401 = React.lazy(() => import('./views/pages/page401/Page401')) const Page403 = React.lazy(() => import('./views/pages/page403/Page403')) @@ -23,12 +29,6 @@ const Login = React.lazy(() => import('./views/pages/login/Login')) const Logout = React.lazy(() => import('./views/pages/login/Logout')) //we loop through the routes array, dynamicly create the component by using dynamicImport, add the component to the route array as 'component' key. -routes.forEach((route) => { - if (route.component) { - route['component'] = dynamicImport(route.component) - } -}) - const App = () => { return ( @@ -54,6 +54,9 @@ const App = () => { > {routes.map((route, idx) => { const allowedRoles = route.allowedRoles + const Routecomponent = dynamicImport(route.path) + console.log('route', route) + console.log('Routecomponent', Routecomponent) return ( route.component && ( { CIPP - {route.name} - +