forked from gitdagray/mern_stack_course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
58 lines (50 loc) · 2.05 KB
/
App.js
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 { Routes, Route } from 'react-router-dom'
import Layout from './components/Layout'
import Public from './components/Public'
import Login from './features/auth/Login';
import DashLayout from './components/DashLayout'
import Welcome from './features/auth/Welcome'
import NotesList from './features/notes/NotesList'
import UsersList from './features/users/UsersList'
import EditUser from './features/users/EditUser'
import NewUserForm from './features/users/NewUserForm'
import EditNote from './features/notes/EditNote'
import NewNote from './features/notes/NewNote'
import Prefetch from './features/auth/Prefetch'
import PersistLogin from './features/auth/PersistLogin'
import RequireAuth from './features/auth/RequireAuth'
import { ROLES } from './config/roles'
function App() {
return (
<Routes>
<Route path="/" element={<Layout />}>
{/* public routes */}
<Route index element={<Public />} />
<Route path="login" element={<Login />} />
{/* Protected Routes */}
<Route element={<PersistLogin />}>
<Route element={<RequireAuth allowedRoles={[...Object.values(ROLES)]} />}>
<Route element={<Prefetch />}>
<Route path="dash" element={<DashLayout />}>
<Route index element={<Welcome />} />
<Route element={<RequireAuth allowedRoles={[ROLES.Manager, ROLES.Admin]} />}>
<Route path="users">
<Route index element={<UsersList />} />
<Route path=":id" element={<EditUser />} />
<Route path="new" element={<NewUserForm />} />
</Route>
</Route>
<Route path="notes">
<Route index element={<NotesList />} />
<Route path=":id" element={<EditNote />} />
<Route path="new" element={<NewNote />} />
</Route>
</Route>{/* End Dash */}
</Route>
</Route>
</Route>{/* End Protected Routes */}
</Route>
</Routes >
);
}
export default App;