feature/IO-3255-simplified-parts-management - Checkpoint
This commit is contained in:
@@ -12,7 +12,7 @@ const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
const mapDispatchToProps = () => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
|
||||
@@ -254,6 +254,21 @@ export function* signInSuccessSaga({ payload }) {
|
||||
window.$crisp.push(["set", "session:segments", [["rome"]]]);
|
||||
}
|
||||
});
|
||||
|
||||
// Hide Crisp if currently in parts-entry mode (pre-shop-details)
|
||||
try {
|
||||
const state = yield select();
|
||||
const isParts = state?.application?.isPartsEntry === true;
|
||||
const instanceSeg = InstanceRenderManager({ imex: "imex", rome: "rome" });
|
||||
// Always ensure segments include instance + user, and append partsManagement if applicable
|
||||
const segs = [currentUserSegment, instanceSeg, ...(isParts ? ["partsManagement"] : [])];
|
||||
window.$crisp.push(["set", "session:segments", [segs]]);
|
||||
if (isParts) {
|
||||
window.$crisp.push(["do", "chat:hide"]);
|
||||
}
|
||||
} catch (e) {
|
||||
// no-op
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error updating Crisp settings.", error);
|
||||
}
|
||||
@@ -337,21 +352,34 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
|
||||
|
||||
try {
|
||||
window.$crisp.push(["set", "user:company", [payload.shopname]]);
|
||||
window.$crisp.push(["set", "session:segments", [[`region:${payload.region_config}`]]]);
|
||||
if (authRecord[0] && authRecord[0].user.validemail) {
|
||||
window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]);
|
||||
}
|
||||
|
||||
payload.features?.allAccess === true
|
||||
? window.$crisp.push(["set", "session:segments", [["allAccess"]]])
|
||||
: (() => {
|
||||
const featureKeys = Object.keys(payload.features).filter(
|
||||
(key) =>
|
||||
payload.features[key] === true ||
|
||||
(typeof payload.features[key] === "string" && !isNaN(Date.parse(payload.features[key])))
|
||||
);
|
||||
window.$crisp.push(["set", "session:segments", [["basic", ...featureKeys]]]);
|
||||
})();
|
||||
// Build consolidated Crisp segments including instance, region, features, and parts mode
|
||||
const isParts = yield select((state) => state.application.isPartsEntry === true);
|
||||
const instanceSeg = InstanceRenderManager({ imex: "imex", rome: "rome" });
|
||||
|
||||
let featureSegments;
|
||||
if (payload.features?.allAccess === true) {
|
||||
featureSegments = ["allAccess"];
|
||||
} else {
|
||||
const featureKeys = Object.keys(payload.features).filter(
|
||||
(key) =>
|
||||
payload.features[key] === true ||
|
||||
(typeof payload.features[key] === "string" && !isNaN(Date.parse(payload.features[key])))
|
||||
);
|
||||
featureSegments = ["basic", ...featureKeys];
|
||||
}
|
||||
|
||||
const regionSeg = payload.region_config ? `region:${payload.region_config}` : null;
|
||||
const segments = [instanceSeg, ...(regionSeg ? [regionSeg] : []), ...featureSegments];
|
||||
if (isParts) segments.push("partsManagement");
|
||||
|
||||
window.$crisp.push(["set", "session:segments", [segments]]);
|
||||
|
||||
// Hide/show Crisp chat based on parts mode
|
||||
window.$crisp.push(["do", isParts ? "chat:hide" : "chat:show"]);
|
||||
|
||||
InstanceRenderManager({
|
||||
executeFunction: true,
|
||||
@@ -364,7 +392,7 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
|
||||
//Set whether it is for parts management only.
|
||||
|
||||
// TODO: This is a temp fix we do not want to do a check on true
|
||||
yield put(setPartsManagementOnly(true || payload.features.partsManagementOnly));
|
||||
yield put(setPartsManagementOnly(true));
|
||||
} catch (error) {
|
||||
console.warn("Couldnt find $crisp.", error.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user