From cc9f342575e4c980321dee17cf44c6b12fd22a15 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 8 May 2024 15:16:03 -0700 Subject: [PATCH] Update expired page, remove RBAC, and prevent sign in. --- .../shop-info/shop-info.general.component.jsx | 791 ++++++++--------- .../shop-info/shop-info.rbac.component.jsx | 792 +++++++++--------- .../shop-info.rostatus.component.jsx | 4 +- .../shop-sub-status.component.jsx | 18 +- client/src/pages/shop/shop.page.component.jsx | 15 +- client/src/redux/user/user.sagas.js | 32 +- 6 files changed, 837 insertions(+), 815 deletions(-) diff --git a/client/src/components/shop-info/shop-info.general.component.jsx b/client/src/components/shop-info/shop-info.general.component.jsx index a961c33e9..20cc88d36 100644 --- a/client/src/components/shop-info/shop-info.general.component.jsx +++ b/client/src/components/shop-info/shop-info.general.component.jsx @@ -13,6 +13,7 @@ import PhoneFormItem, { PhoneItemFormatterValidation } from "../form-items-forma import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import InstanceRenderManager from "../../utils/instanceRenderMgr"; +import FeatureWrapper, { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component"; // TODO: Client Update, this might break const timeZonesList = Intl.supportedValuesOf("timeZone"); const mapStateToProps = createStructuredSelector({ @@ -144,285 +145,289 @@ export function ShopInfoGeneral({ form, bodyshop }) { - - - - - {InstanceRenderManager({ - imex: ( - - {() => ( + null}> + + + + + {InstanceRenderManager({ + imex: ( + + {() => ( + + + + )} + + ) + })} + + + + + + 2 + 3 + + + + {() => { + return ( - + + {t("bodyshop.labels.2tiername")} + {t("bodyshop.labels.2tiersource")} + - )} - - ) - })} - - - - - - 2 - 3 - - - - {() => { - return ( + ); + }} + + + + + + + + + + + + + + {InstanceRenderManager({ + imex: ( + + + + ) + })} + + + + {InstanceRenderManager({ + imex: ( - - {t("bodyshop.labels.2tiername")} - {t("bodyshop.labels.2tiersource")} - + - ); - }} - - - - - - - - - - - - - - {InstanceRenderManager({ - imex: ( - - - - ) - })} - - - - {InstanceRenderManager({ - imex: ( - - - - ) - })} - - - - - - - - - - - - - - {ReceivableCustomFieldSelect} - - - {ReceivableCustomFieldSelect} - - - {ReceivableCustomFieldSelect} - - { - return { - required: getFieldValue("enforce_class"), + ) + })} + + + + + + + - + + + + + {ClosingPeriod.treatment === "on" && ( + <> + + + + + )} + + + null}> + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + null}> + + + {(fields, { add, remove, move }) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - { - remove(field.name); - }} - /> - - - + + { + remove(field.name); + }} + /> + + + + + ))} + + - ))} - - - -
- ); - }} -
-
+ + ); + }} + +
+ + {(fields, { add, remove, move }) => { diff --git a/client/src/components/shop-info/shop-info.rbac.component.jsx b/client/src/components/shop-info/shop-info.rbac.component.jsx index f26dc1938..8be57a559 100644 --- a/client/src/components/shop-info/shop-info.rbac.component.jsx +++ b/client/src/components/shop-info/shop-info.rbac.component.jsx @@ -1,12 +1,13 @@ +import { useSplitTreatments } from "@splitsoftware/splitio-react"; import { Form, InputNumber } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; +import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component"; -import { useSplitTreatments } from "@splitsoftware/splitio-react"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop @@ -29,210 +30,227 @@ export function ShopInfoRbacComponent({ form, bodyshop }) { return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + {HasFeatureAccess({ featureName: "export", bodyshop }) && ( + <> + + + + + + + + + + + + + + )} + {HasFeatureAccess({ featureName: "bills", bodyshop }) && ( + <> + + + + + + + + + + + + + + + + + )} + + {HasFeatureAccess({ featureName: "courtesycars", bodyshop }) && ( + <> + + + + + + + + + + + + + + + + + + + + )} + {HasFeatureAccess({ featureName: "csi", bodyshop }) && ( + <> + + + + + + + + )} - - - - - - + {HasFeatureAccess({ featureName: "visualboard", bodyshop }) && ( + + + + )} + - - - - - - - - - - - - - - - - - - - - - - - - + {HasFeatureAccess({ featureName: "scoreboard", bodyshop }) && ( + + + + )} + {HasFeatureAccess({ featureName: "timetickets", bodyshop }) && ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + )} - - - - - - - - - - - - - - - - - - - - + */} + {HasFeatureAccess({ featureName: "media", bodyshop }) && ( + + + + )} + { return (
- + {fields.map((field, index) => ( @@ -386,7 +386,7 @@ export function ShopInfoROStatusComponent({ bodyshop, form }) { ))} - + - } - /> - ); + return ; } diff --git a/client/src/pages/shop/shop.page.component.jsx b/client/src/pages/shop/shop.page.component.jsx index 19991f62f..97f34ea95 100644 --- a/client/src/pages/shop/shop.page.component.jsx +++ b/client/src/pages/shop/shop.page.component.jsx @@ -72,10 +72,17 @@ export function ShopPage({ bodyshop, setSelectedHeader, setBreadcrumbs }) { }); } - items.push({ - key: "licensing", - label: t("bodyshop.labels.licensing"), - children: + InstanceRenderManager({ + executeFunction: true, + args: [], + imex: () => { + items.push({ + key: "licensing", + label: t("bodyshop.labels.licensing"), + children: + }); + }, + rome: "USE_IMEX" }); if (HasFeatureAccess({ featureName: "csi", bodyshop })) { diff --git a/client/src/redux/user/user.sagas.js b/client/src/redux/user/user.sagas.js index 0c5aae651..283d8c48e 100644 --- a/client/src/redux/user/user.sagas.js +++ b/client/src/redux/user/user.sagas.js @@ -15,6 +15,7 @@ import { getToken } from "firebase/messaging"; import i18next from "i18next"; import LogRocket from "logrocket"; import { all, call, delay, put, select, takeLatest } from "redux-saga/effects"; +import { Userpilot } from "userpilot"; import { factory } from "../../App/App.container"; import { analytics, @@ -25,6 +26,10 @@ import { messaging, updateCurrentUser } from "../../firebase/firebase.utils"; +import { QUERY_EULA } from "../../graphql/bodyshop.queries"; +import client from "../../utils/GraphQLClient"; +import day from "../../utils/day"; +import InstanceRenderManager from "../../utils/instanceRenderMgr"; import { checkInstanceId, sendPasswordResetFailure, @@ -43,11 +48,6 @@ import { validatePasswordResetSuccess } from "./user.actions"; import UserActionTypes from "./user.types"; -import client from "../../utils/GraphQLClient"; -import { QUERY_EULA } from "../../graphql/bodyshop.queries"; -import day from "../../utils/day"; -import InstanceRenderManager from "../../utils/instanceRenderMgr"; -import { Userpilot } from "userpilot"; const fpPromise = FingerprintJS.load(); @@ -310,10 +310,28 @@ export function* SetAuthLevelFromShopDetails({ payload }) { updateUserDetailsSuccess(authRecord[0] ? { validemail: authRecord[0].user.validemail } : { validemail: false }) ); + const user = yield select((state) => state.user.currentUser); if (payload.features.singleDeviceOnly) { - const user = yield select((state) => state.user.currentUser); + if (!(user.email.includes("@imex.") || user.email.includes("@rome.") || user.email.includes("@promanager."))) + yield put(setInstanceId(user.uid)); + } - if (!(user.email.includes("@imex.") || user.email.includes("@rome."))) yield put(setInstanceId(user.uid)); + //For Rome, check to make sure it's not a PM shop. + try { + InstanceRenderManager({ + executeFunction: true, + args: [], + rome: () => { + if ( + payload.imexshopid.toLowerCase().startsWith("pm_") && + !(user.email.includes("@imex.") || user.email.includes("@rome.") || user.email.includes("@promanager.")) + ) { + throw new Error("You are not authorized to use this application."); + } + } + }); + } catch (error) { + yield put(setInstanceConflict()); } try {