-
Notifications
You must be signed in to change notification settings - Fork 479
/
application_dashboard.jsx
130 lines (120 loc) · 4.01 KB
/
application_dashboard.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* Main landing page and router for the application dashboard.
*/
import React, {PropTypes} from 'react';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import applicationDashboardReducers, {
setRegionalPartnerName,
setRegionalPartners,
setWorkshopAdminPermission,
setLockApplicationPermission,
} from './reducers';
import Header from '../components/header';
import {
Router,
Route,
IndexRedirect,
useRouterHistory
} from 'react-router';
import {createHistory} from 'history';
import Summary from './summary';
import QuickView from './quick_view';
import DetailView from './detail_view';
import CohortView from './cohort_view';
import _ from 'lodash';
const ROOT_PATH = '/pd/application_dashboard';
const browserHistory = useRouterHistory(createHistory)({
basename: ROOT_PATH
});
const store = createStore(applicationDashboardReducers);
const ApplicationDashboardHeader = (props) => (
<Header
baseName="Application Dashboard"
{...props}
/>
);
const paths = {
'csf_facilitators': {type: 'facilitator', name: 'CS Fundamentals Facilitator Applications'},
'csd_facilitators': {type: 'facilitator', name: 'CS Discoveries Facilitator Applications'},
'csp_facilitators': {type: 'facilitator', name: 'CS Principles Facilitator Applications'},
'csd_teachers': {type: 'teacher', name: 'CS Discoveries Teacher Applications'},
'csp_teachers': {type: 'teacher', name: 'CS Principles Teacher Applications'}
};
export default class ApplicationDashboard extends React.Component {
static propTypes = {
regionalPartnerName: PropTypes.string,
regionalPartners: PropTypes.array,
isWorkshopAdmin: PropTypes.bool,
canLockApplications: PropTypes.bool,
};
componentWillMount() {
if (this.props.regionalPartnerName) {
store.dispatch(setRegionalPartnerName(this.props.regionalPartnerName));
}
if (this.props.regionalPartners) {
store.dispatch(setRegionalPartners(this.props.regionalPartners));
}
if (this.props.isWorkshopAdmin) {
store.dispatch(setWorkshopAdminPermission(true));
}
if (this.props.canLockApplications) {
store.dispatch(setLockApplicationPermission(true));
}
}
render() {
return (
<Provider store={store}>
<Router history={browserHistory} >
<Route path="/" component={ApplicationDashboardHeader}>
<IndexRedirect to="/summary" />
<Route
path="summary"
breadcrumbs="Summary"
component={Summary}
/>
{
_.flatten(Object.keys(paths).map((path, i) => {
const cohort_path_name = paths[path].name.replace('Applications', 'Cohort');
return [
(
<Route
key={`detail_${i}`}
path={`${path}/(:applicationId)`}
breadcrumbs={[
{name: paths[path].name, path: path},
{name: 'Application Details', path: ''}
]}
component={DetailView}
viewType={paths[path].type}
/>
),
(
<Route
key={`quick_view_${i}`}
path={path}
breadcrumbs={paths[path].name}
component={QuickView}
applicationType={paths[path].name}
viewType={paths[path].type}
/>
),
(
<Route
key={`cohort_view_${i}`}
path={`${path}_cohort`}
breadcrumbs={cohort_path_name}
component={CohortView}
applicationType={cohort_path_name}
viewType={paths[path].type}
/>
)
];
}))
}
</Route>
</Router>
</Provider>
);
}
}