-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.jsx
93 lines (88 loc) · 2.74 KB
/
index.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React from 'react';
import ReactDOM from 'react-dom/client';
import {
RouterProvider,
createBrowserRouter,
createRoutesFromElements,
Route,
Link
} from "react-router-dom"
import Home from "./pages/Home"
import About from "./pages/About"
import Vans, { loader as vansLoader } from "./pages/Vans/Vans"
import VanDetail, { loader as vanDetailLoader } from "./pages/Vans/VanDetail"
import Dashboard, { loader as dashboardLoader } from "./pages/Host/Dashboard"
import Income from "./pages/Host/Income"
import Reviews from "./pages/Host/Reviews"
import HostVans, { loader as hostVansLoader } from "./pages/Host/HostVans"
import HostVanDetail, { loader as hostVansDetailLoader } from "./pages/Host/HostVanDetail"
import HostVanInfo from "./pages/Host/HostVanInfo"
import HostVanPricing from "./pages/Host/HostVanPricing"
import HostVanPhotos from "./pages/Host/HostVanPhotos"
import NotFound from "./pages/NotFound"
import Login, { action as loginAction } from "./pages/Login"
import Layout from "./components/Layout"
import HostLayout from "./components/HostLayout"
import Error from "./components/Error"
import AuthRequired from "./components/AuthRequired"
import "./server"
const router = createBrowserRouter(createRoutesFromElements(
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="about" element={<About />} />
<Route
path="login"
element={<Login />}
action={loginAction}
/>
<Route
path="vans"
element={<Vans />}
errorElement={<Error />}
loader={vansLoader}
/>
<Route
path="vans/:id"
element={<VanDetail />}
errorElement={<Error />}
loader={vanDetailLoader}
/>
<Route element={<AuthRequired />}>
<Route path="host" element={<HostLayout />} >
<Route
index
element={<Dashboard />}
errorElement={<Error />}
loader={dashboardLoader}
/>
<Route path="income" element={<Income />} />
<Route path="reviews" element={<Reviews />} />
<Route
path="vans"
element={<HostVans />}
errorElement={<Error />}
loader={hostVansLoader}
/>
<Route
path="vans/:id"
element={<HostVanDetail />}
errorElement={<Error />}
loader={hostVansDetailLoader}
>
<Route index element={<HostVanInfo />} />
<Route path="pricing" element={<HostVanPricing />} />
<Route path="photos" element={<HostVanPhotos />} />
</Route>
</Route>
</Route>
<Route path="*" element={<NotFound />} />
</Route>
))
function App() {
return (
<RouterProvider router={router} />
)
}
ReactDOM
.createRoot(document.getElementById('root'))
.render(<App />);