PromucFlow_constructor/app/client/src/index.tsx

77 lines
2.7 KiB
TypeScript
Raw Normal View History

2019-12-03 09:21:06 +00:00
import React, { lazy, Suspense } from "react";
2020-01-14 09:47:45 +00:00
import { Helmet } from "react-helmet";
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, Redirect } from "react-router-dom";
import history from "./utils/history";
2019-12-30 07:35:16 +00:00
import { ThemeProvider, theme } from "constants/DefaultTheme";
import { DndProvider } from "react-dnd";
2019-10-09 09:08:55 +00:00
import HTML5Backend from "react-dnd-html5-backend";
2019-12-30 07:35:16 +00:00
import { appInitializer } from "utils/AppsmithUtils";
import ProtectedRoute from "./pages/common/ProtectedRoute";
import store from "./store";
import {
BASE_URL,
BUILDER_URL,
APP_VIEW_URL,
APPLICATIONS_URL,
ORG_URL,
2019-12-16 08:49:10 +00:00
USER_AUTH_URL,
AUTH_LOGIN_URL,
SIGN_UP_URL,
BASE_LOGIN_URL,
BASE_SIGNUP_URL,
2019-12-30 07:35:16 +00:00
} 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"));
const Organization = lazy(() => import("./pages/organization"));
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
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}>
2020-01-14 09:47:45 +00:00
<Helmet>
<meta charSet="utf-8" />
<link rel="shortcut icon" href="/favicon-orange.ico" />
</Helmet>
<Router history={history}>
2019-12-03 09:21:06 +00:00
<Suspense fallback={loadingIndicator}>
<Switch>
<ProtectedRoute exact path={BASE_URL} component={App} />
<ProtectedRoute path={ORG_URL} component={Organization} />
2019-12-16 08:49:10 +00:00
<Route path={USER_AUTH_URL} component={UserAuth} />
<Redirect exact from={BASE_LOGIN_URL} to={AUTH_LOGIN_URL} />
<Redirect exact from={BASE_SIGNUP_URL} to={SIGN_UP_URL} />
2019-12-03 09:21:06 +00:00
<ProtectedRoute
exact
path={APPLICATIONS_URL}
component={Applications}
/>
<ProtectedRoute path={BUILDER_URL} component={Editor} />
<ProtectedRoute path={APP_VIEW_URL} component={AppViewer} />
2019-12-03 09:21:06 +00:00
<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();