From 213634bba8c9df2bb1fbc66c7a2aa7b67629dfc9 Mon Sep 17 00:00:00 2001
From: Patrick Fic <>
Date: Tue, 9 Mar 2021 13:00:45 -0800
Subject: [PATCH] Resolve no shop access.
---
bodyshop_translations.babel | 21 +++++++++++++++++++
.../components/no-shop/no-shop.component.jsx | 12 +++++++++++
.../pages/manage/manage.page.container.jsx | 17 ++++++++++++---
client/src/redux/user/user.sagas.js | 5 ++---
client/src/translations/en_us/common.json | 1 +
client/src/translations/es/common.json | 1 +
client/src/translations/fr/common.json | 1 +
7 files changed, 52 insertions(+), 6 deletions(-)
create mode 100644 client/src/components/no-shop/no-shop.component.jsx
diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel
index 3dcf01ed0..8a0d985a5 100644
--- a/bodyshop_translations.babel
+++ b/bodyshop_translations.babel
@@ -12186,6 +12186,27 @@
+
+ noshop
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
notfoundsub
false
diff --git a/client/src/components/no-shop/no-shop.component.jsx b/client/src/components/no-shop/no-shop.component.jsx
new file mode 100644
index 000000000..1847999e9
--- /dev/null
+++ b/client/src/components/no-shop/no-shop.component.jsx
@@ -0,0 +1,12 @@
+import React from "react";
+import { Result } from "antd";
+import { useTranslation } from "react-i18next";
+
+export default function NoShop() {
+ const { t } = useTranslation();
+ return (
+
+
+
+ );
+}
diff --git a/client/src/pages/manage/manage.page.container.jsx b/client/src/pages/manage/manage.page.container.jsx
index 719b27f47..c7e06ecf3 100644
--- a/client/src/pages/manage/manage.page.container.jsx
+++ b/client/src/pages/manage/manage.page.container.jsx
@@ -7,12 +7,17 @@ import { setBodyshop } from "../../redux/user/user.actions";
import ManagePage from "./manage.page.component";
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
import { useTranslation } from "react-i18next";
+import { createStructuredSelector } from "reselect";
+import { selectBodyshop } from "../../redux/user/user.selectors";
+import NoShop from "../../components/no-shop/no-shop.component";
+
+const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop });
const mapDispatchToProps = (dispatch) => ({
setBodyshop: (bs) => dispatch(setBodyshop(bs)),
});
-function ManagePageContainer({ match, setBodyshop }) {
+function ManagePageContainer({ match, setBodyshop, bodyshop }) {
const { loading, error, data } = useQuery(QUERY_BODYSHOP, {
fetchPolicy: "network-only",
});
@@ -20,13 +25,19 @@ function ManagePageContainer({ match, setBodyshop }) {
const { t } = useTranslation();
useEffect(() => {
- if (data) setBodyshop(data.bodyshops[0]);
+ if (data) setBodyshop(data.bodyshops[0] || { notfound: true });
}, [data, setBodyshop]);
if (loading)
return ;
if (error) return ;
+
+ if (bodyshop && bodyshop.notfound) return ;
+
return ;
}
-export default connect(null, mapDispatchToProps)(ManagePageContainer);
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(ManagePageContainer);
diff --git a/client/src/redux/user/user.sagas.js b/client/src/redux/user/user.sagas.js
index a8f6b49bf..84e8178a6 100644
--- a/client/src/redux/user/user.sagas.js
+++ b/client/src/redux/user/user.sagas.js
@@ -15,7 +15,6 @@ import {
sendPasswordResetSuccess,
setAuthlevel,
setInstanceConflict,
- setInstanceId,
setLocalFingerprint,
signInFailure,
signInSuccess,
@@ -160,7 +159,7 @@ export function* onSignInSuccess() {
export function* signInSuccessSaga({ payload }) {
LogRocket.identify(payload.email);
- if (!payload.email.includes("@imex.")) yield put(setInstanceId(payload.uid));
+ // if (!payload.email.includes("@imex.")) yield put(setInstanceId(payload.uid));
analytics.setUserId(payload.email);
analytics.setUserProperties(payload);
yield logImEXEvent("redux_sign_in_success");
@@ -177,7 +176,7 @@ export function* sendPasswordResetEmail({ payload }) {
yield auth.sendPasswordResetEmail(payload, {
url: "https://imex.online/passwordreset",
});
- console.log("Good should send.");
+
yield put(sendPasswordResetSuccess());
} catch (error) {
yield put(sendPasswordResetFailure(error.message));
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json
index c768b9ab2..fc8fc5e5a 100644
--- a/client/src/translations/en_us/common.json
+++ b/client/src/translations/en_us/common.json
@@ -782,6 +782,7 @@
"newversionmessage": "Click refresh below to update to the latest available version of ImEX Online.",
"newversiontitle": "New version of ImEX Online Available",
"noacctfilepath": "There is no accounting file path set. You will not be able to export any items.",
+ "noshop": "You do not have access to any shops. Please reach out to your shop manager or technical support. ",
"notfoundsub": "Please make sure that you have access to the data or that the link is correct.",
"notfoundtitle": "We couldn't find what you're looking for...",
"partnernotrunning": "ImEX Online has detected that the partner is not running. Please ensure it is running to enable full functionality.",
diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json
index f0f3cfe23..a28b9ec70 100644
--- a/client/src/translations/es/common.json
+++ b/client/src/translations/es/common.json
@@ -782,6 +782,7 @@
"newversionmessage": "",
"newversiontitle": "",
"noacctfilepath": "",
+ "noshop": "",
"notfoundsub": "",
"notfoundtitle": "",
"partnernotrunning": "",
diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json
index cdd25258b..d735e7970 100644
--- a/client/src/translations/fr/common.json
+++ b/client/src/translations/fr/common.json
@@ -782,6 +782,7 @@
"newversionmessage": "",
"newversiontitle": "",
"noacctfilepath": "",
+ "noshop": "",
"notfoundsub": "",
"notfoundtitle": "",
"partnernotrunning": "",