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