Task 9: Create React Router configuration with lazy loading and route structure

This commit is contained in:
gnezim
2026-04-05 19:20:23 +03:00
parent 4b34a78890
commit 95f49d7deb
8 changed files with 104 additions and 5 deletions
+10 -5
View File
@@ -1,8 +1,13 @@
export default function App() {
import React, { Suspense } from 'react'
import { RouterProvider } from 'react-router-dom'
import { router } from './router/router'
const App: React.FC = () => {
return (
<div className="app" data-testid="page-loaded">
<h1>Aeroflot Flights - React Migration</h1>
<p>Coming soon...</p>
</div>
<Suspense fallback={<div>Loading...</div>}>
<RouterProvider router={router} />
</Suspense>
)
}
export default App
+10
View File
@@ -0,0 +1,10 @@
import React from 'react'
export const BoardPage: React.FC = () => {
return (
<div className="board-page">
<h1>Online Board</h1>
<p>Arrivals and Departures</p>
</div>
)
}
@@ -0,0 +1,10 @@
import React from 'react'
export const FlightsMapPage: React.FC = () => {
return (
<div className="flights-map-page">
<h1>Flights Map</h1>
<p>Real-time Flight Map</p>
</div>
)
}
+11
View File
@@ -0,0 +1,11 @@
import React from 'react'
export const NotFound: React.FC = () => {
return (
<div className="page-not-found">
<h1>404 - Page Not Found</h1>
<p>The page you are looking for does not exist.</p>
<a href="/">Back to Home</a>
</div>
)
}
+10
View File
@@ -0,0 +1,10 @@
import React from 'react'
export const SchedulePage: React.FC = () => {
return (
<div className="schedule-page">
<h1>Schedule</h1>
<p>Flight Schedule</p>
</div>
)
}
+10
View File
@@ -0,0 +1,10 @@
import React from 'react'
export const StartPage: React.FC = () => {
return (
<div className="start-page">
<h1>Aeroflot Flights - Home</h1>
<p>Welcome to Aeroflot Flights</p>
</div>
)
}
+4
View File
@@ -0,0 +1,4 @@
import { createBrowserRouter } from 'react-router-dom'
import routes from './routes'
export const router = createBrowserRouter(routes)
+39
View File
@@ -0,0 +1,39 @@
import { RouteObject } from 'react-router-dom'
import { NotFound } from '../pages/NotFound'
const routes: RouteObject[] = [
{
path: '/',
lazy: async () => {
const { StartPage } = await import('../pages/StartPage')
return { Component: StartPage }
},
},
{
path: '/board',
lazy: async () => {
const { BoardPage } = await import('../pages/BoardPage')
return { Component: BoardPage }
},
},
{
path: '/schedule',
lazy: async () => {
const { SchedulePage } = await import('../pages/SchedulePage')
return { Component: SchedulePage }
},
},
{
path: '/flights-map',
lazy: async () => {
const { FlightsMapPage } = await import('../pages/FlightsMapPage')
return { Component: FlightsMapPage }
},
},
{
path: '*',
element: <NotFound />,
},
]
export default routes