PromucFlow_constructor/app/client/src/index.tsx

132 lines
3.9 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";
2020-03-11 13:59:46 +00:00
import { Router, 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 { appInitializer } from "utils/AppsmithUtils";
2020-03-11 13:59:46 +00:00
import AppRoute from "./pages/common/AppRoute";
2020-02-18 10:41:52 +00:00
import { Slide, ToastContainer } from "react-toastify";
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,
2020-01-31 10:46:43 +00:00
USERS_URL,
2019-12-30 07:35:16 +00:00
} from "constants/routes";
2020-05-28 18:10:26 +00:00
import { LayersContext, Layers } from "constants/Layers";
2019-12-03 09:21:06 +00:00
const loadingIndicator = <Loader />;
2020-04-17 04:59:43 +00:00
const App = lazy(() =>
import(/* webpackChunkName: "appsmith",webpackPrefetch: 10 */ "./App"),
);
const UserAuth = lazy(() =>
2020-04-16 13:00:53 +00:00
import(/* webpackChunkName: "auth",webpackPrefetch: 5 */ "./pages/UserAuth"),
);
const Editor = lazy(() =>
import(/* webpackChunkName: "editor",webpackPrefetch: 3 */ "./pages/Editor"),
);
const Applications = lazy(() =>
2020-04-16 13:00:53 +00:00
import(
/* webpackChunkName: "apps",webpackPrefetch: 4 */ "./pages/Applications"
),
);
const PageNotFound = lazy(() =>
2020-04-17 04:59:43 +00:00
import(/* webpackChunkName: "404"*/ "./pages/common/PageNotFound"),
);
const AppViewer = lazy(() =>
2020-04-16 13:00:53 +00:00
import(
/* webpackChunkName: "viewer",webpackPrefetch: 2 */ "./pages/AppViewer"
),
);
const Organization = lazy(() =>
2020-04-17 04:59:43 +00:00
import(/* webpackChunkName: "orgs" */ "./pages/organization"),
);
const Users = lazy(() => import(/* webpackPrefetch: true */ "./pages/users"));
2019-09-02 15:36:24 +00:00
appInitializer();
2019-11-21 10:52:49 +00:00
ReactDOM.render(
<Provider store={store}>
2020-05-28 18:10:26 +00:00
<LayersContext.Provider value={Layers}>
<ThemeProvider theme={theme}>
<ToastContainer
hideProgressBar
draggable={false}
transition={Slide}
autoClose={5000}
closeButton={false}
/>
<Helmet>
<meta charSet="utf-8" />
<link rel="shortcut icon" href="/favicon-orange.ico" />
</Helmet>
<Router history={history}>
<Suspense fallback={loadingIndicator}>
<Switch>
<AppRoute
exact
path={BASE_URL}
component={App}
name={"App"}
routeProtected
/>
<AppRoute
path={ORG_URL}
component={Organization}
name={"Organisation"}
routeProtected
/>
<AppRoute
exact
path={USERS_URL}
component={Users}
name={"Users"}
routeProtected
/>
<AppRoute
path={USER_AUTH_URL}
component={UserAuth}
name={"UserAuth"}
/>
<Redirect exact from={BASE_LOGIN_URL} to={AUTH_LOGIN_URL} />
<Redirect exact from={BASE_SIGNUP_URL} to={SIGN_UP_URL} />
<AppRoute
exact
path={APPLICATIONS_URL}
component={Applications}
name={"Home"}
routeProtected
/>
<AppRoute
path={BUILDER_URL}
component={Editor}
name={"Editor"}
routeProtected
/>
<AppRoute
path={APP_VIEW_URL}
component={AppViewer}
name={"AppViewer"}
routeProtected
logDisable
/>
<AppRoute component={PageNotFound} name={"PageNotFound"} />
</Switch>
</Suspense>
</Router>
</ThemeProvider>
</LayersContext.Provider>
</Provider>,
document.getElementById("root"),
2019-03-16 11:33:15 +00:00
);