-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
51 lines (40 loc) · 1.5 KB
/
index.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
const develop = (process.env.NODE_ENV !== 'production');
var React = require('react');
var ReactDOM = require('react-dom');
var { syncHistoryWithStore } = require('react-router-redux');
var history = require('./routing/history');
var configureStore = require('./store/configureStore');
var Root = require('./containers/Root');
var { setLocale } = require('./actions/LocaleActions');
var { refreshProfile } = require('./actions/SessionActions');
var store = configureStore();
history = syncHistoryWithStore(history, store);
var renderRoot = function () {
ReactDOM.render(
<Root store={store} history={history} />,
document.getElementById('root')
);
};
// http://stackoverflow.com/questions/10730362/get-cookie-by-name
var getCookie = function (name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) {
return parts.pop().split(";").shift();
}
};
var locale = getCookie('daiad-utility-locale') || 'en-GB';
var mustRefresh = (getCookie('daiad-utility-session') === 'true');
// Chain preliminary actions needed before any rendering takes place
store.dispatch(setLocale(locale, true))
.then(() => (mustRefresh ? store.dispatch(refreshProfile()) : Promise.resolve()))
.then(renderRoot);
// If under development, shortcut some modules into global namespace (window)
if (develop) {
global.$a = {
api: require('./api/base'),
};
}
//custom leaflet image path
var L = require('leaflet');
L.Icon.Default.imagePath = '/assets/lib/leaflet/images/';