-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.jsx
58 lines (53 loc) · 2.04 KB
/
App.jsx
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Navigate, Route, Routes } from "react-router-dom";
import { lazy, Suspense } from "react";
// import Product from "";
// import Pricing from "./assets/Pricing";
// import Homepage from "";
// import PageNotFound from "./assets/PageNotFound";
// import AppLayout from "./assets/AppLayout";
// import Login from "./assets/Login";
import CityList from "./components/CityList";
import CountryList from "./components/CountryList";
import City from './components/City';
import Form from './components/Form';
import { CitiesProvider } from "./contexts/CitiesContext";
import { AuthProvider } from "./contexts/FakeAuthContext";
import ProtectedRoute from "./assets/ProtectedRoute";
const Homepage = lazy(() => import('./assets/Homepage'))
const Product = lazy(() => import('./assets/Product'))
const Pricing = lazy(() => import('./assets/Pricing'))
const Login = lazy(() => import('./assets/Login'))
const AppLayout = lazy(() => import('./assets/AppLayout'))
const PageNotFound = lazy(() => import('./assets/PageNotFound'));
import SpinnerFullPage from './components/SpinnerFullPage'
export default function App () {
return (
<>
<AuthProvider>
<CitiesProvider>
<Suspense fallback={<SpinnerFullPage />} >
<Routes >
<Route path="/" element={<Homepage/>} />
<Route path="/product" element={<Product/>} />
<Route path="/pricing" element={<Pricing/>} />
<Route path="app"
element={
<ProtectedRoute>
<AppLayout/>
</ProtectedRoute>
}>
<Route index element={<Navigate replace to={'cities'} /> } />
<Route path="cities" element={<CityList />} />
<Route path="cities/:id" element={<City />} />
<Route path="countries" element ={<CountryList />} />
<Route path="form" element={<Form />} />
</Route>
<Route path="/login" element={<Login />} />
<Route path="*" element={<PageNotFound/>} />
</Routes>
</Suspense>
</CitiesProvider>
</AuthProvider>
</>
)
}