forked from byu-osl/cityvoice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
58 lines (52 loc) · 1.68 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
'use strict';
var globals = require('global'); // just runs global.js
var React = require('react');
var Router = require('react-router');
var {Route, RouteHandler} = Router;
var Navbar = require('./Navbar');
var api = require('server-api');
React.getDOMNode = React.findDOMNode;
React.initializeTouchEvents(true);
var App = React.createClass({
componentWillMount: function authenticate() {
window.issueTrackerUser = {};
var token = localStorage.getItem('issueTrackerToken');
if (!token) {
window.issueTrackerUser = {};
} else {
api.authenticate(token, function (user) {
if (user.authenticated === false) {
window.issueTrackerUser = {};
} else {
window.issueTrackerUser = user;
window.issueTrackerUser.loggedIn = true;
}
}, this);
}
},
render: function() {
return (
<div>
<Navbar></Navbar>
<div style={{padding:10}}>
<RouteHandler />
</div>
</div>
)
}
});
var routes = (
<Route handler={App}>
<Route name='/' handler={require('./HomePage')}/>
<Route name='issue-submission' handler={require('./request-form/RequestForm')}/>
<Route name='admin' handler={require('./admin/AdminPage')}>
<Route name='requests' handler={require('./admin/Requests')}></Route>
<Route name='services' handler={require('./admin/Services')}></Route>
<Route name='users' handler={require('./admin/Users')}></Route>
</Route>
<Route name='requests/:id' handler={require('./individual-request/RequestPage')}></Route>
</Route>
);
Router.run(routes, Router.HashLocation, function (Root) {
React.render(<Root />, $('.app-container')[0]);
});