IO-1138 Offline detection.
This commit is contained in:
@@ -12968,6 +12968,48 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>nointernet</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>nointernet_sub</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>none</name>
|
<name>none</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ if (process.env.NODE_ENV === "production") LogRocket.init("gvfvfw/bodyshopapp");
|
|||||||
|
|
||||||
export default function AppContainer() {
|
export default function AppContainer() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ApolloProvider client={client}>
|
<ApolloProvider client={client}>
|
||||||
<ConfigProvider
|
<ConfigProvider
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button, Result } from "antd";
|
||||||
import React, { lazy, Suspense, useEffect } from "react";
|
import React, { lazy, Suspense, useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -8,6 +9,8 @@ import ErrorBoundary from "../components/error-boundary/error-boundary.component
|
|||||||
import LoadingSpinner from "../components/loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../components/loading-spinner/loading-spinner.component";
|
||||||
import AboutPage from "../pages/about/about.page";
|
import AboutPage from "../pages/about/about.page";
|
||||||
import TechPageContainer from "../pages/tech/tech.page.container";
|
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 { checkUserSession } from "../redux/user/user.actions";
|
||||||
import { selectCurrentUser } from "../redux/user/user.selectors";
|
import { selectCurrentUser } from "../redux/user/user.selectors";
|
||||||
import PrivateRoute from "../utils/private-route";
|
import PrivateRoute from "../utils/private-route";
|
||||||
@@ -27,12 +30,14 @@ const MobilePaymentContainer = lazy(() =>
|
|||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentUser: selectCurrentUser,
|
currentUser: selectCurrentUser,
|
||||||
|
online: selectOnline,
|
||||||
});
|
});
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
checkUserSession: () => dispatch(checkUserSession()),
|
checkUserSession: () => dispatch(checkUserSession()),
|
||||||
|
setOnline: (isOnline) => dispatch(setOnline(isOnline)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export function App({ checkUserSession, currentUser }) {
|
export function App({ checkUserSession, currentUser, online, setOnline }) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
checkUserSession();
|
checkUserSession();
|
||||||
}, [checkUserSession]);
|
}, [checkUserSession]);
|
||||||
@@ -42,10 +47,38 @@ export function App({ checkUserSession, currentUser }) {
|
|||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
window.addEventListener("offline", function (e) {
|
||||||
|
console.log("Internet connection lost.");
|
||||||
|
setOnline(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener("online", function (e) {
|
||||||
|
setOnline(true);
|
||||||
|
});
|
||||||
|
|
||||||
if (currentUser.authorized === null) {
|
if (currentUser.authorized === null) {
|
||||||
return <LoadingSpinner message={t("general.labels.loggingin")} />;
|
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 (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Suspense fallback={<LoadingSpinner message="ImEX Online" />}>
|
<Suspense fallback={<LoadingSpinner message="ImEX Online" />}>
|
||||||
|
|||||||
@@ -48,3 +48,8 @@ export const setPartnerVersion = (version) => ({
|
|||||||
type: ApplicationActionTypes.SET_PARTNER_VERSION,
|
type: ApplicationActionTypes.SET_PARTNER_VERSION,
|
||||||
payload: version,
|
payload: version,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const setOnline = (isOnline) => ({
|
||||||
|
type: ApplicationActionTypes.SET_ONLINE_STATUS,
|
||||||
|
payload: isOnline,
|
||||||
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import ApplicationActionTypes from "./application.types";
|
|||||||
|
|
||||||
const INITIAL_STATE = {
|
const INITIAL_STATE = {
|
||||||
loading: false,
|
loading: false,
|
||||||
|
online: true,
|
||||||
breadcrumbs: [],
|
breadcrumbs: [],
|
||||||
recentItems: [],
|
recentItems: [],
|
||||||
selectedHeader: "home",
|
selectedHeader: "home",
|
||||||
@@ -21,6 +22,11 @@ const applicationReducer = (state = INITIAL_STATE, action) => {
|
|||||||
...state,
|
...state,
|
||||||
selectedHeader: action.payload,
|
selectedHeader: action.payload,
|
||||||
};
|
};
|
||||||
|
case ApplicationActionTypes.SET_ONLINE_STATUS:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
online: action.payload,
|
||||||
|
};
|
||||||
case ApplicationActionTypes.ADD_RECENT_ITEM:
|
case ApplicationActionTypes.ADD_RECENT_ITEM:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|||||||
@@ -40,3 +40,7 @@ export const selectJobReadOnly = createSelector(
|
|||||||
[selectApplication],
|
[selectApplication],
|
||||||
(application) => application.jobReadOnly
|
(application) => application.jobReadOnly
|
||||||
);
|
);
|
||||||
|
export const selectOnline = createSelector(
|
||||||
|
[selectApplication],
|
||||||
|
(application) => application.online
|
||||||
|
);
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ const ApplicationActionTypes = {
|
|||||||
SET_SELECTED_HEADER: "SET_SELECTED_HEADER",
|
SET_SELECTED_HEADER: "SET_SELECTED_HEADER",
|
||||||
SET_JOB_READONLY: "SET_JOB_READONLY",
|
SET_JOB_READONLY: "SET_JOB_READONLY",
|
||||||
SET_PARTNER_VERSION: "SET_PARTNER_VERSION",
|
SET_PARTNER_VERSION: "SET_PARTNER_VERSION",
|
||||||
|
SET_ONLINE_STATUS: "SET_ONLINE_STATUS",
|
||||||
};
|
};
|
||||||
export default ApplicationActionTypes;
|
export default ApplicationActionTypes;
|
||||||
|
|||||||
@@ -821,6 +821,8 @@
|
|||||||
"monday": "Monday",
|
"monday": "Monday",
|
||||||
"na": "N/A",
|
"na": "N/A",
|
||||||
"no": "No",
|
"no": "No",
|
||||||
|
"nointernet": "It looks like you're not connected to the internet.",
|
||||||
|
"nointernet_sub": "Please check your connection and try again. ",
|
||||||
"none": "None",
|
"none": "None",
|
||||||
"out": "Out",
|
"out": "Out",
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
|
|||||||
@@ -821,6 +821,8 @@
|
|||||||
"monday": "",
|
"monday": "",
|
||||||
"na": "N / A",
|
"na": "N / A",
|
||||||
"no": "",
|
"no": "",
|
||||||
|
"nointernet": "",
|
||||||
|
"nointernet_sub": "",
|
||||||
"none": "",
|
"none": "",
|
||||||
"out": "Afuera",
|
"out": "Afuera",
|
||||||
"password": "",
|
"password": "",
|
||||||
|
|||||||
@@ -821,6 +821,8 @@
|
|||||||
"monday": "",
|
"monday": "",
|
||||||
"na": "N / A",
|
"na": "N / A",
|
||||||
"no": "",
|
"no": "",
|
||||||
|
"nointernet": "",
|
||||||
|
"nointernet_sub": "",
|
||||||
"none": "",
|
"none": "",
|
||||||
"out": "En dehors",
|
"out": "En dehors",
|
||||||
"password": "",
|
"password": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user