DocSpace-client/web/ASC.Web.Client/src/index.js
Artem Tarasov 7cccd43f22 fix
2020-07-06 15:14:20 +03:00

45 lines
1.2 KiB
JavaScript

import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import store from "./store/store";
import "./custom.scss";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import { store as commonStore, constants, history, ErrorBoundary} from "asc-web-common";
const {
getUserInfo,
getPortalSettings,
setIsLoaded
} = commonStore.auth.actions;
const { AUTH_KEY } = constants;
const token = localStorage.getItem(AUTH_KEY);
if (!token) {
getPortalSettings(store.dispatch)
.then(() => store.dispatch(setIsLoaded(true)))
.catch(e => history.push(`/login/error=${e}`));
} else if (!window.location.pathname.includes("confirm/EmailActivation")) {
getUserInfo(store.dispatch)
.then(() => store.dispatch(setIsLoaded(true)))
.catch(e => history.push(`/login/error=${e}`));
}
ReactDOM.render(
<Provider store={store}>
<ErrorBoundary>
<App />
</ErrorBoundary>
</Provider>,
document.getElementById("root")
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.register();