forked from wsi-cogs/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
127 lines (111 loc) · 5.3 KB
/
index.js
File metadata and controls
127 lines (111 loc) · 5.3 KB
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
/*
Copyright (c) 2018 Genome Research Ltd.
Authors:
* Simon Beal <sb48@sanger.ac.uk>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import React, {Component} from 'react';
import {
BrowserRouter as Router,
Route,
Switch
} from 'react-router-dom';
import thunkMiddleware from 'redux-thunk';
import { createLogger } from 'redux-logger';
import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux'
import ReactDOM from 'react-dom';
import rootReducer from './reducers/root.js';
import MainPage from './pages/main_page.js';
import DefaultPage from './pages/default_page.js';
import {fetchMe} from './actions/users'
import Header from './header.js';
import { connect } from 'react-redux';
import Alert from 'react-s-alert';
import 'react-s-alert/dist/s-alert-default.css';
import 'react-s-alert/dist/s-alert-css-effects/stackslide.css';
import './index.css';
import {fetchLatestRotation} from './actions/rotations.js';
import Projects from './pages/projects.js';
import MarkableProjects from './pages/markable_projects.js'
import EmailEditor from './pages/email_edit.js';
import UserEditor from './pages/user_edit.js';
import RotationCreate from './pages/rotation_create.js';
import ProjectCreate from './pages/project_create.js';
import ProjectResubmit from './pages/project_resubmit.js';
import ProjectEdit from './pages/project_edit.js';
import RotationCogsEditor from './pages/rotation_cogs_edit.js';
import RotationChoiceViewer from './pages/rotation_choices_view.js'
import RotationChoiceChooser from './pages/rotation_choices_finalise.js'
import RotationCogsFinalise from './pages/rotation_choices_cogs.js'
import ProjectUpload from './pages/project_upload'
import ProjectMark from './pages/project_mark'
import {ProjectFeedbackSupervisor, ProjectFeedbackCogs} from './pages/project_feedback'
const loggerMiddleware = createLogger()
const store = createStore(
rootReducer,
applyMiddleware(
thunkMiddleware // lets us dispatch() functions
//,loggerMiddleware // neat middleware that logs actions
)
)
class App extends Component {
async componentDidMount() {
store.dispatch(fetchMe());
store.dispatch(fetchLatestRotation());
}
render() {
if (!(this.props.loggedInID && this.props.latestRotationID)) {return ""}
return (
<Provider store={store}>
<Router>
<div>
<Header/>
<Switch>
<Route exact path="/" component={MainPage}/>
<Route exact path="/projects" component={Projects}/>
<Route exact path="/projects/markable" component={MarkableProjects}/>
<Route exact path="/emails/edit" component={EmailEditor}/>
<Route exact path="/users/edit" component={UserEditor}/>
<Route exact path="/rotations/create" component={RotationCreate}/>
<Route exact path="/projects/create" component={ProjectCreate}/>
<Route exact path="/projects/upload" component={ProjectUpload}/>
<Route exact path="/projects/:projectID/resubmit" component={ProjectResubmit}/>
<Route exact path="/projects/:projectID/edit" component={ProjectEdit}/>
<Route exact path="/projects/:projectID/provide_feedback" component={ProjectMark}/>
<Route exact path="/projects/:projectID/supervisor_feedback" component={ProjectFeedbackSupervisor}/>
<Route exact path="/projects/:projectID/cogs_feedback" component={ProjectFeedbackCogs}/>
<Route exact path="/rotations/choices/cogs" component={RotationCogsFinalise}/>
<Route exact path="/rotations/choices/view" component={RotationChoiceViewer}/>
<Route exact path="/rotations/choices/finalise" component={RotationChoiceChooser}/>
<Route exact path="/rotations/:partID/cogs" component={RotationCogsEditor}/>
<Route component={DefaultPage} />
</Switch>
<Alert stack={{limit: 3}} effect="stackslide"/>
</div>
</Router>
</Provider>
);
}
}
const mapStateToProps = state => {
return {
loggedInID: state.users.loggedInID,
latestRotationID: state.rotations.latestID
}
};
const mapDispatchToProps = dispatch => {return {}};
const ConnectedApp = connect(
mapStateToProps,
mapDispatchToProps
)(App)
ReactDOM.render(<ConnectedApp store={store}/>, document.getElementById('root'));