2016-03-18 11:51:22 -04:00
|
|
|
|
var redux = require('redux');
|
|
|
|
|
var thunk = require('redux-thunk').default;
|
2015-10-15 23:11:09 -04:00
|
|
|
|
var ReactDOM = require('react-dom');
|
2016-03-18 11:51:22 -04:00
|
|
|
|
var StoreProvider = require('react-redux').Provider;
|
2015-12-16 12:00:42 -05:00
|
|
|
|
|
2016-03-18 10:54:26 -04:00
|
|
|
|
var IntlProvider = require('./intl.jsx').IntlProvider;
|
2016-03-18 11:51:22 -04:00
|
|
|
|
var actions = require('../redux/actions.js');
|
|
|
|
|
var reducer = require('../redux/reducer.js');
|
2015-10-15 23:11:09 -04:00
|
|
|
|
|
2016-01-14 14:20:21 -05:00
|
|
|
|
require('../main.scss');
|
|
|
|
|
|
2016-03-18 11:51:22 -04:00
|
|
|
|
var store = redux.createStore(
|
|
|
|
|
reducer,
|
|
|
|
|
redux.applyMiddleware(thunk)
|
|
|
|
|
);
|
2016-01-14 08:16:02 -05:00
|
|
|
|
|
2016-01-08 13:50:58 -05:00
|
|
|
|
var render = function (jsx, element) {
|
2015-10-15 23:11:09 -04:00
|
|
|
|
// Get locale and messages from global namespace (see "init.js")
|
2016-01-06 14:09:32 -05:00
|
|
|
|
var locale = window._locale || 'en';
|
2016-05-12 17:57:48 -04:00
|
|
|
|
var messages = {};
|
|
|
|
|
if (typeof window._messages !== 'undefined') {
|
|
|
|
|
if (typeof window._messages[locale] === 'undefined') {
|
|
|
|
|
// Fall back on the split
|
|
|
|
|
locale = locale.split('-')[0];
|
|
|
|
|
}
|
|
|
|
|
if (typeof window._messages[locale] === 'undefined') {
|
|
|
|
|
// Language appears to not be supported – fall back to 'en'
|
|
|
|
|
locale = 'en';
|
|
|
|
|
}
|
|
|
|
|
messages = window._messages[locale];
|
2016-01-06 14:09:32 -05:00
|
|
|
|
}
|
2015-10-15 23:11:09 -04:00
|
|
|
|
|
2016-01-14 08:16:02 -05:00
|
|
|
|
// Render view component
|
2016-03-18 10:54:26 -04:00
|
|
|
|
ReactDOM.render(
|
2016-03-18 11:51:22 -04:00
|
|
|
|
<StoreProvider store={store}>
|
|
|
|
|
<IntlProvider locale={locale} messages={messages}>
|
|
|
|
|
{jsx}
|
|
|
|
|
</IntlProvider>
|
|
|
|
|
</StoreProvider>,
|
2015-10-15 23:11:09 -04:00
|
|
|
|
element
|
|
|
|
|
);
|
|
|
|
|
|
2016-03-18 11:51:22 -04:00
|
|
|
|
// Get initial session
|
|
|
|
|
store.dispatch(actions.refreshSession());
|
2015-10-15 23:11:09 -04:00
|
|
|
|
};
|
2015-10-16 15:10:17 -04:00
|
|
|
|
|
|
|
|
|
module.exports = render;
|