2020-02-25 06:58:09 +00:00
|
|
|
import React from "react";
|
|
|
|
import ReactDOM from "react-dom";
|
|
|
|
import { Provider } from "react-redux";
|
|
|
|
import store from "./store/store";
|
2020-03-04 05:41:36 +00:00
|
|
|
import { fetchMyFolder, fetchRootFolders, fetchFiles } from "./store/files/actions";
|
2020-02-25 06:58:09 +00:00
|
|
|
import config from "../package.json";
|
|
|
|
import "./custom.scss";
|
|
|
|
import App from "./App";
|
|
|
|
|
|
|
|
import * as serviceWorker from "./serviceWorker";
|
2020-03-18 13:01:22 +00:00
|
|
|
import { store as commonStore, constants, ErrorBoundary, history } from "asc-web-common";
|
2020-03-13 15:11:15 +00:00
|
|
|
import { getFilterByLocation } from "./helpers/converters";
|
2020-02-25 06:58:09 +00:00
|
|
|
const { setIsLoaded, getUserInfo, setCurrentProductId, setCurrentProductHomePage, getPortalPasswordSettings, getPortalCultures } = commonStore.auth.actions;
|
|
|
|
const { AUTH_KEY } = constants;
|
|
|
|
|
|
|
|
const token = localStorage.getItem(AUTH_KEY);
|
|
|
|
|
|
|
|
if (token) {
|
|
|
|
getUserInfo(store.dispatch)
|
2020-02-28 10:33:13 +00:00
|
|
|
.then(() => getPortalPasswordSettings(store.dispatch))
|
|
|
|
.then(() => getPortalCultures(store.dispatch))
|
2020-03-18 13:01:22 +00:00
|
|
|
//.then(() => fetchGroups(store.dispatch))
|
2020-02-28 10:33:13 +00:00
|
|
|
.then(() => fetchMyFolder(store.dispatch))
|
2020-02-28 13:08:03 +00:00
|
|
|
.then(() => fetchRootFolders(store.dispatch))
|
2020-02-28 10:33:13 +00:00
|
|
|
.then(() => {
|
2020-03-13 15:11:15 +00:00
|
|
|
const re = new RegExp(`${config.homepage}((/?)$|/filter)`, "gm");
|
|
|
|
const match = window.location.pathname.match(re);
|
2020-02-25 06:58:09 +00:00
|
|
|
|
2020-03-13 15:11:15 +00:00
|
|
|
if (match && match.length > 0) {
|
|
|
|
const newFilter = getFilterByLocation(window.location);
|
2020-03-18 13:01:22 +00:00
|
|
|
const folderId = window.location.hash.slice(1) || '@my';
|
|
|
|
return fetchFiles(folderId, newFilter, store.dispatch);
|
2020-03-13 15:11:15 +00:00
|
|
|
}
|
2020-03-18 13:01:22 +00:00
|
|
|
|
|
|
|
return Promise.resolve();
|
2020-02-28 10:33:13 +00:00
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
store.dispatch(setCurrentProductHomePage(config.homepage));
|
|
|
|
store.dispatch(setCurrentProductId("e67be73d-f9ae-4ce1-8fec-1880cb518cb4"));
|
|
|
|
store.dispatch(setIsLoaded(true));
|
|
|
|
});
|
2020-02-25 06:58:09 +00:00
|
|
|
}
|
2020-02-28 10:33:13 +00:00
|
|
|
else {
|
2020-02-25 06:58:09 +00:00
|
|
|
store.dispatch(setIsLoaded(true));
|
|
|
|
};
|
|
|
|
|
|
|
|
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();
|