Big progress!
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { useSplitClient} from "@splitsoftware/splitio-react";
|
||||
import { Button, Result } from "antd";
|
||||
import {useSplitClient} from "@splitsoftware/splitio-react";
|
||||
import {Button, Result} from "antd";
|
||||
import LogRocket from "logrocket";
|
||||
import React, { lazy, Suspense, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { Route, Routes } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import React, {lazy, Suspense, useEffect} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {connect} from "react-redux";
|
||||
import {Route, Routes} from "react-router-dom";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import DocumentEditorContainer from "../components/document-editor/document-editor.container";
|
||||
import ErrorBoundary from "../components/error-boundary/error-boundary.component";
|
||||
//Component Imports
|
||||
@@ -13,174 +13,123 @@ import LoadingSpinner from "../components/loading-spinner/loading-spinner.compon
|
||||
import DisclaimerPage from "../pages/disclaimer/disclaimer.page";
|
||||
import LandingPage from "../pages/landing/landing.page";
|
||||
import TechPageContainer from "../pages/tech/tech.page.container";
|
||||
import { setOnline } from "../redux/application/application.actions";
|
||||
import { selectOnline } from "../redux/application/application.selectors";
|
||||
import { checkUserSession } from "../redux/user/user.actions";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../redux/user/user.selectors";
|
||||
import PrivateRoute from "../utils/private-route";
|
||||
import {setOnline} from "../redux/application/application.actions";
|
||||
import {selectOnline} from "../redux/application/application.selectors";
|
||||
import {checkUserSession} from "../redux/user/user.actions";
|
||||
import {selectBodyshop, selectCurrentUser,} from "../redux/user/user.selectors";
|
||||
import PrivateRoute from "../components/PrivateRoute";
|
||||
import "./App.styles.scss";
|
||||
import {JobsPage} from "../pages/jobs/jobs.page";
|
||||
|
||||
const ResetPassword = lazy(() =>
|
||||
import("../pages/reset-password/reset-password.component")
|
||||
import("../pages/reset-password/reset-password.component")
|
||||
);
|
||||
const ManagePage = lazy(() => import("../pages/manage/manage.page.container"));
|
||||
const SignInPage = lazy(() => import("../pages/sign-in/sign-in.page"));
|
||||
|
||||
const CsiPage = lazy(() => import("../pages/csi/csi.container.page"));
|
||||
const MobilePaymentContainer = lazy(() =>
|
||||
import("../pages/mobile-payment/mobile-payment.container")
|
||||
import("../pages/mobile-payment/mobile-payment.container")
|
||||
);
|
||||
const ManageRootPage = lazy(() =>
|
||||
import("../pages/manage-root/manage-root.page.container")
|
||||
);
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
online: selectOnline,
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
online: selectOnline,
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
checkUserSession: () => dispatch(checkUserSession()),
|
||||
setOnline: (isOnline) => dispatch(setOnline(isOnline)),
|
||||
checkUserSession: () => dispatch(checkUserSession()),
|
||||
setOnline: (isOnline) => dispatch(setOnline(isOnline)),
|
||||
});
|
||||
|
||||
export function App({
|
||||
bodyshop,
|
||||
checkUserSession,
|
||||
currentUser,
|
||||
online,
|
||||
setOnline,
|
||||
}) {
|
||||
const client = useSplitClient().client;
|
||||
bodyshop,
|
||||
checkUserSession,
|
||||
currentUser,
|
||||
online,
|
||||
setOnline,
|
||||
}) {
|
||||
const client = useSplitClient().client;
|
||||
|
||||
useEffect(() => {
|
||||
if (!navigator.onLine) {
|
||||
setOnline(false);
|
||||
}
|
||||
|
||||
checkUserSession();
|
||||
}, [checkUserSession, setOnline]);
|
||||
|
||||
//const b = Grid.useBreakpoint();
|
||||
// console.log("Breakpoints:", b);
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
window.addEventListener("offline", function (e) {
|
||||
setOnline(false);
|
||||
});
|
||||
|
||||
window.addEventListener("online", function (e) {
|
||||
setOnline(true);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (currentUser.authorized && bodyshop) {
|
||||
client.setAttribute("imexshopid", bodyshop.imexshopid);
|
||||
|
||||
if (client.getTreatment("LogRocket_Tracking") === "on") {
|
||||
console.log("LR Start");
|
||||
LogRocket.init("gvfvfw/bodyshopapp");
|
||||
}
|
||||
}
|
||||
}, [bodyshop, client, currentUser.authorized]);
|
||||
|
||||
if (currentUser.authorized === null) {
|
||||
return <LoadingSpinner message={t("general.labels.loggingin")} />;
|
||||
}
|
||||
|
||||
if (!online)
|
||||
return (
|
||||
<Result
|
||||
status="warning"
|
||||
title={t("general.labels.nointernet")}
|
||||
subTitle={t("general.labels.nointernet_sub")}
|
||||
extra={
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
window.location.reload();
|
||||
}}
|
||||
>
|
||||
{t("general.actions.refresh")}
|
||||
</Button>
|
||||
useEffect(() => {
|
||||
if (!navigator.onLine) {
|
||||
setOnline(false);
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
// <Switch>
|
||||
// <Suspense fallback={<LoadingSpinner message="ImEX Online" />}>
|
||||
// <ErrorBoundary>
|
||||
// <Route exact path="/" component={LandingPage} />
|
||||
// </ErrorBoundary>
|
||||
// <ErrorBoundary>
|
||||
// <Route exact path="/signin" component={SignInPage} />
|
||||
// </ErrorBoundary>
|
||||
// <ErrorBoundary>
|
||||
// <Route exact path="/resetpassword" component={ResetPassword} />
|
||||
// </ErrorBoundary>
|
||||
// <ErrorBoundary>
|
||||
// <Route exact path="/csi/:surveyId" component={CsiPage} />
|
||||
// </ErrorBoundary>
|
||||
// <ErrorBoundary>
|
||||
// <Route exact path="/disclaimer" component={DisclaimerPage} />
|
||||
// </ErrorBoundary>
|
||||
// <ErrorBoundary>
|
||||
// <Route
|
||||
// exact
|
||||
// path="/mp/:paymentIs"
|
||||
// component={MobilePaymentContainer}
|
||||
// />
|
||||
// </ErrorBoundary>
|
||||
// <ErrorBoundary>
|
||||
// <PrivateRoute
|
||||
// isAuthorized={currentUser.authorized}
|
||||
// path="/manage"
|
||||
// component={ManagePage}
|
||||
// />
|
||||
// </ErrorBoundary>
|
||||
// <ErrorBoundary>
|
||||
// <PrivateRoute
|
||||
// isAuthorized={currentUser.authorized}
|
||||
// path="/tech"
|
||||
// component={TechPageContainer}
|
||||
// />
|
||||
// </ErrorBoundary>
|
||||
// <ErrorBoundary>
|
||||
// <PrivateRoute
|
||||
// isAuthorized={currentUser.authorized}
|
||||
// path="/edit"
|
||||
// component={DocumentEditorContainer}
|
||||
// />
|
||||
// </ErrorBoundary>
|
||||
// </Suspense>
|
||||
// </Switch>
|
||||
checkUserSession();
|
||||
}, [checkUserSession, setOnline]);
|
||||
|
||||
//const b = Grid.useBreakpoint();
|
||||
// console.log("Breakpoints:", b);
|
||||
|
||||
const {t} = useTranslation();
|
||||
|
||||
window.addEventListener("offline", function (e) {
|
||||
setOnline(false);
|
||||
});
|
||||
|
||||
window.addEventListener("online", function (e) {
|
||||
setOnline(true);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (currentUser.authorized && bodyshop) {
|
||||
client.setAttribute("imexshopid", bodyshop.imexshopid);
|
||||
|
||||
if (client.getTreatment("LogRocket_Tracking") === "on") {
|
||||
console.log("LR Start");
|
||||
LogRocket.init("gvfvfw/bodyshopapp");
|
||||
}
|
||||
}
|
||||
}, [bodyshop, client, currentUser.authorized]);
|
||||
|
||||
if (currentUser.authorized === null) {
|
||||
return <LoadingSpinner message={t("general.labels.loggingin")}/>;
|
||||
}
|
||||
|
||||
if (!online)
|
||||
return (
|
||||
<Result
|
||||
status="warning"
|
||||
title={t("general.labels.nointernet")}
|
||||
subTitle={t("general.labels.nointernet_sub")}
|
||||
extra={
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
window.location.reload();
|
||||
}}
|
||||
>
|
||||
{t("general.actions.refresh")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
return (
|
||||
<Suspense fallback={<LoadingSpinner message="ImEX Online" />}>
|
||||
<ErrorBoundary>
|
||||
return (
|
||||
<Suspense fallback={<LoadingSpinner message="ImEX Online"/>}>
|
||||
<Routes>
|
||||
<Route path="/" element={<LandingPage />} />
|
||||
<Route path="/signin" element={<SignInPage />} />
|
||||
<Route path="/resetpassword" element={<ResetPassword />} />
|
||||
<Route path="/csi/:surveyId" element={<CsiPage />} />
|
||||
<Route path="/disclaimer" element={<DisclaimerPage />} />
|
||||
<Route path="/mp/:paymentIs" element={<MobilePaymentContainer />} />
|
||||
<Route path="/manage" element={<PrivateRoute isAuthorized={currentUser.authorized} />}>
|
||||
<Route path="/manage/*" element={<ManagePage />} />
|
||||
</Route>
|
||||
<Route path="/tech" element={<PrivateRoute isAuthorized={currentUser.authorized} />}>
|
||||
<Route path="/tech/*" element={<TechPageContainer />} />
|
||||
</Route>
|
||||
<Route path="/edit" element={<PrivateRoute isAuthorized={currentUser.authorized} />}>
|
||||
<Route path="/edit/*" element={<DocumentEditorContainer />} />
|
||||
</Route>
|
||||
<Route path="/" element={<ErrorBoundary><LandingPage/></ErrorBoundary>}/>
|
||||
<Route path="/signin" element={<ErrorBoundary><SignInPage/></ErrorBoundary>}/>
|
||||
<Route path="/resetpassword" element={<ErrorBoundary><ResetPassword/></ErrorBoundary>}/>
|
||||
<Route path="/csi/:surveyId" element={<ErrorBoundary><CsiPage/></ErrorBoundary>}/>
|
||||
<Route path="/disclaimer" element={<ErrorBoundary><DisclaimerPage/></ErrorBoundary>}/>
|
||||
<Route path="/mp/:paymentIs" element={<ErrorBoundary><MobilePaymentContainer/></ErrorBoundary>}/>
|
||||
<Route path="/manage" element={<ErrorBoundary><PrivateRoute isAuthorized={currentUser.authorized}/></ErrorBoundary>}>
|
||||
<Route path='/manage/' element={<ManageRootPage/>}/>
|
||||
<Route path="/manage/*" element={<ManagePage/>}/>
|
||||
</Route>
|
||||
<Route path="/tech" element={<ErrorBoundary><PrivateRoute isAuthorized={currentUser.authorized}/></ErrorBoundary>}>
|
||||
<Route path="/tech/*" element={<TechPageContainer/>}/>
|
||||
</Route>
|
||||
<Route path="/edit" element={<PrivateRoute isAuthorized={currentUser.authorized}/>}>
|
||||
<Route path="/edit/*" element={<DocumentEditorContainer/>}/>
|
||||
</Route>
|
||||
</Routes>
|
||||
</ErrorBoundary>
|
||||
</Suspense>
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(App);
|
||||
|
||||
Reference in New Issue
Block a user