-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 1.03 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
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import Cookies from 'js-cookie';
import './sass/index.css';
import queryString from 'query-string';
import { has } from 'lodash';
import { setUserID, getCurrentUser, verifyLoginChallenge, logout } from './actions/auth';
import store from './store';
const App = process.env.REACT_APP_STAGE !== 'admin' ? require('./AdminApp').default : require('./App').default;
const userid = Cookies.get('USER_ID');
const parsedParams = queryString.parse(window.location.search);
if (has(parsedParams, 'login_challenge')) {
store.dispatch(verifyLoginChallenge(parsedParams.login_challenge));
} else if (/(forgotverify)|(verify)/.test(window.location.pathname)) {
store.dispatch(logout());
} else if (process.env.REACT_APP_STAGE !== 'admin' && typeof userid !== 'undefined') {
store.dispatch(setUserID(userid));
store.dispatch(getCurrentUser());
}
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root'),
);