forked from freeCodeCamp/pantry-for-good
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRouter.js
55 lines (48 loc) · 2.16 KB
/
Router.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
import React from 'react'
import {ConnectedRouter} from 'react-router-redux'
import {Route} from 'react-router-dom'
import {ADMIN_ROLE, clientRoles} from '../common/constants'
import Sidebar from './modules/core/components/sidebar/Sidebar'
import Header from './modules/core/components/Header'
import Footer from './modules/core/components/Footer'
import Home from './modules/core/components/Home'
import Dialog from './modules/core/components/Dialog'
import Title from './modules/core/components/Title'
import Customers from './modules/customer/CustomerRouter'
import Donors from './modules/donor/DonorRouter'
import Drivers from './modules/driver/DriverRouter'
import Inventory from './modules/food/components/Inventory'
import Schedule from './modules/food/components/Schedule'
import Packing from './modules/food/components/Packing'
import Settings from './modules/settings/SettingsRouter'
import Users from './modules/users/UserRouter'
import Volunteers from './modules/volunteer/VolunteerRouter'
import requireRole from './components/router/requireRole'
import SwitchWithNotFound from './components/router/SwitchWithNotFound'
const IsAdmin = requireRole([ADMIN_ROLE])
const IsVolunteer = requireRole([ADMIN_ROLE, clientRoles.VOLUNTEER])
const Router = ({history}) =>
<ConnectedRouter history={history}>
<div>
<Title />
<Sidebar />
<Header />
<Dialog />
<div className="content-wrapper">
<SwitchWithNotFound>
<Route exact path="/" component={Home} />
<Route path="/customers" component={Customers} />
<Route path="/donors" component={Donors} />
<Route path="/drivers" component={Drivers} />
<Route path="/inventory" exact component={IsVolunteer(Inventory)} />
<Route path="/packing" exact component={IsVolunteer(Packing)} />
<Route path="/schedule" exact component={IsVolunteer(Schedule)} />
<Route path="/settings" component={IsAdmin(Settings)} />
<Route path="/users" component={Users} />
<Route path="/volunteers" component={Volunteers} />
</SwitchWithNotFound>
</div>
<Footer />
</div>
</ConnectedRouter>
export default Router