PromucFlow_constructor/app/client/src/index.tsx

76 lines
2.6 KiB
TypeScript
Raw Normal View History

2019-12-03 09:21:06 +00:00
import React, { lazy, Suspense } from "react";
2019-03-16 11:33:15 +00:00
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
2019-12-03 09:21:06 +00:00
import Loader from "pages/common/Loader";
2019-03-16 11:33:15 +00:00
import "./index.css";
import * as serviceWorker from "./serviceWorker";
import { Router, Route, Switch } from "react-router-dom";
import { createStore, applyMiddleware } from "redux";
import history from "./utils/history";
2019-03-16 11:33:15 +00:00
import appReducer from "./reducers";
import { ThemeProvider, theme } from "./constants/DefaultTheme";
import createSagaMiddleware from "redux-saga";
import { rootSaga } from "./sagas";
import { DndProvider } from "react-dnd";
2019-10-09 09:08:55 +00:00
// import TouchBackend from "react-dnd-touch-backend";
import HTML5Backend from "react-dnd-html5-backend";
2019-08-30 10:33:49 +00:00
import { appInitializer } from "./utils/AppsmithUtils";
import ProtectedRoute from "./pages/common/ProtectedRoute";
import { composeWithDevTools } from "redux-devtools-extension/logOnlyInProduction";
2019-11-21 10:52:49 +00:00
import {
BASE_URL,
BUILDER_URL,
APP_VIEW_URL,
APPLICATIONS_URL,
2019-12-16 08:49:10 +00:00
USER_AUTH_URL,
} from "./constants/routes";
2019-12-03 09:21:06 +00:00
const loadingIndicator = <Loader />;
const App = lazy(() => import("./App"));
2019-12-16 08:49:10 +00:00
const UserAuth = lazy(() => import("./pages/UserAuth"));
2019-12-03 09:21:06 +00:00
const Editor = lazy(() => import("./pages/Editor"));
const Applications = lazy(() => import("./pages/Applications"));
const PageNotFound = lazy(() => import("./pages/common/PageNotFound"));
const AppViewer = lazy(() => import("./pages/AppViewer"));
2019-09-05 17:47:50 +00:00
2019-09-02 15:36:24 +00:00
appInitializer();
2019-11-21 10:52:49 +00:00
const sagaMiddleware = createSagaMiddleware();
const store = createStore(
appReducer,
composeWithDevTools(applyMiddleware(sagaMiddleware)),
);
sagaMiddleware.run(rootSaga);
2019-11-21 10:52:49 +00:00
ReactDOM.render(
2019-10-09 09:08:55 +00:00
<DndProvider backend={HTML5Backend}>
2019-08-26 12:41:21 +00:00
<Provider store={store}>
<ThemeProvider theme={theme}>
<Router history={history}>
2019-12-03 09:21:06 +00:00
<Suspense fallback={loadingIndicator}>
<Switch>
<Route exact path={BASE_URL} component={App} />
2019-12-16 08:49:10 +00:00
<Route path={USER_AUTH_URL} component={UserAuth} />
2019-12-03 09:21:06 +00:00
<ProtectedRoute path={BUILDER_URL} component={Editor} />
<ProtectedRoute path={APP_VIEW_URL} component={AppViewer} />
<ProtectedRoute
exact
path={APPLICATIONS_URL}
component={Applications}
/>
<Route component={PageNotFound} />
</Switch>
</Suspense>
</Router>
2019-08-26 12:41:21 +00:00
</ThemeProvider>
</Provider>
</DndProvider>,
document.getElementById("root"),
2019-03-16 11:33:15 +00:00
);
2019-01-21 15:11:10 +00:00
// 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: http://bit.ly/CRA-PWA
2019-03-16 11:33:15 +00:00
serviceWorker.unregister();