All files / src/router index.tsx

0% Statements 0/23
0% Branches 0/1
0% Functions 0/1
0% Lines 0/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                                                         
import { lazy, Suspense } from 'react'
import { createBrowserRouter, RouterProvider } from 'react-router-dom'
import { Box, CircularProgress, Typography } from '@mui/material'
 
const UploadView = lazy(() => import('../views/UploadView'))
const ExtractionView = lazy(() => import('../views/ExtractionView'))
const AnalyseView = lazy(() => import('../views/AnalyseView'))
const ContexteView = lazy(() => import('../views/ContexteView'))
const ConseilView = lazy(() => import('../views/ConseilView'))
 
const LoadingFallback = () => (
  <Box sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', minHeight: '50vh' }}>
    <CircularProgress />
    <Typography sx={{ ml: 2 }}>Chargement...</Typography>
  </Box>
)
 
const router = createBrowserRouter([
  { path: '/', element: <Suspense fallback={<LoadingFallback />}><UploadView /></Suspense> },
  { path: '/extraction', element: <Suspense fallback={<LoadingFallback />}><ExtractionView /></Suspense> },
  { path: '/analyse', element: <Suspense fallback={<LoadingFallback />}><AnalyseView /></Suspense> },
  { path: '/contexte', element: <Suspense fallback={<LoadingFallback />}><ContexteView /></Suspense> },
  { path: '/conseil', element: <Suspense fallback={<LoadingFallback />}><ConseilView /></Suspense> },
])
 
export const AppRouter = () => {
  return <RouterProvider router={router} />
}