thm-p3-configurator 0.0.95 → 0.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -380,7 +380,7 @@ const useProductsQuery = orderParameters => {
|
|
|
380
380
|
// NOTE: the API to enrich the products with extra data is only available when the configurator has an authenticated user, so on in the PP.
|
|
381
381
|
// If we need this also for the public version than Hyper needs to implement this.
|
|
382
382
|
|
|
383
|
-
|
|
383
|
+
try {
|
|
384
384
|
var _data$articles7, _data$articles8, _data$articles9, _data$articles10, _data$articles11;
|
|
385
385
|
// Enrich all products with brands and prices
|
|
386
386
|
const enrichedProducts = await (0, _singleOrderArticles.enrichArticlesWithBrandsAndPrices)(allProducts, branchId, formula);
|
|
@@ -398,7 +398,7 @@ const useProductsQuery = orderParameters => {
|
|
|
398
398
|
extras: ((_data$articles11 = data.articles) === null || _data$articles11 === void 0 || (_data$articles11 = _data$articles11.extras) === null || _data$articles11 === void 0 ? void 0 : _data$articles11.map(product => _objectSpread(_objectSpread({}, product), enrichedProductsMap[product.articleNumber]))) || []
|
|
399
399
|
})
|
|
400
400
|
});
|
|
401
|
-
}
|
|
401
|
+
} catch (_unused) {
|
|
402
402
|
return data;
|
|
403
403
|
}
|
|
404
404
|
}
|
|
@@ -77,7 +77,7 @@ const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
|
|
|
77
77
|
return (branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 || (_authSession$branch = _authSession$branch.organisatietype) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch[0]]) === null || _branchTypes$byId$aut === void 0 ? void 0 : _branchTypes$byId$aut.title) === _constants__.TMG_ORGANIZATION_TYPE;
|
|
78
78
|
}, [branchTypes, authSession]);
|
|
79
79
|
let locations;
|
|
80
|
-
if (isTMGOrganization) {
|
|
80
|
+
if (isTMGOrganization || !APP_CONFIG.internal) {
|
|
81
81
|
const {
|
|
82
82
|
branches
|
|
83
83
|
} = (0, _queries.useBranchesQuery)({
|
|
@@ -94,7 +94,7 @@ const NormalPageModalContent = _ref => {
|
|
|
94
94
|
var _branches$;
|
|
95
95
|
if (!(_branches !== null && _branches !== void 0 && _branches.length)) return;
|
|
96
96
|
if (selectedBranch) return;
|
|
97
|
-
const shouldAutoSelect = !
|
|
97
|
+
const shouldAutoSelect = !existingDossierId && !isTMGOrganization && _branches.length === 1;
|
|
98
98
|
if (!shouldAutoSelect) return;
|
|
99
99
|
const branchToSelect = (_branches$ = _branches[0]) === null || _branches$ === void 0 ? void 0 : _branches$.entityId;
|
|
100
100
|
if (branchToSelect) {
|
|
@@ -248,6 +248,14 @@ const InternalBranchSelectorModal = () => {
|
|
|
248
248
|
selectedBranch,
|
|
249
249
|
existingDossierId
|
|
250
250
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
251
|
+
const {
|
|
252
|
+
myBranches,
|
|
253
|
+
isLoadingMyBranches
|
|
254
|
+
} = (0, _queries.useMyBranches)(formula);
|
|
255
|
+
const shouldAutoSelect = _react.default.useMemo(() => {
|
|
256
|
+
if (isSingleOrderPage) return false;
|
|
257
|
+
return !existingDossierId && !isTMGOrganization && !selectedBranch && (myBranches === null || myBranches === void 0 ? void 0 : myBranches.length) === 1;
|
|
258
|
+
}, [existingDossierId, isTMGOrganization, selectedBranch, myBranches, isSingleOrderPage]);
|
|
251
259
|
const handlePrimaryButtonClicked = () => {
|
|
252
260
|
dispatch({
|
|
253
261
|
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_BRANCH,
|
|
@@ -256,13 +264,13 @@ const InternalBranchSelectorModal = () => {
|
|
|
256
264
|
}
|
|
257
265
|
});
|
|
258
266
|
};
|
|
259
|
-
|
|
267
|
+
const shouldShowModalForSingleOrder = APP_CONFIG.internal && !selectedBranch && !existingDossierId && isSingleOrderPage;
|
|
268
|
+
const shouldShowModalForOtherPages = APP_CONFIG.internal && !selectedBranch && !existingDossierId && !isSingleOrderPage && !isTMGOrganization && !shouldAutoSelect && !isLoadingMyBranches;
|
|
269
|
+
if (isLoadingBranchTypes || isLoadingMyBranches) {
|
|
260
270
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
261
271
|
className: "thm-configurator-wrapper--offset"
|
|
262
|
-
},
|
|
272
|
+
}, /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null));
|
|
263
273
|
}
|
|
264
|
-
const shouldShowModalForSingleOrder = APP_CONFIG.internal && !selectedBranch && !existingDossierId && isSingleOrderPage;
|
|
265
|
-
const shouldShowModalForOtherPages = APP_CONFIG.internal && !selectedBranch && !existingDossierId && !isSingleOrderPage && !isTMGOrganization;
|
|
266
274
|
return /*#__PURE__*/_react.default.createElement(_Modal.default, {
|
|
267
275
|
isOpen: shouldShowModalForSingleOrder || shouldShowModalForOtherPages,
|
|
268
276
|
title: 'Kies een vestiging:',
|
|
@@ -8,17 +8,18 @@ var _react = require("react");
|
|
|
8
8
|
var _queries = require("../__api__/queries");
|
|
9
9
|
var _constants__ = require("../__constants__");
|
|
10
10
|
var _useAuthSession = require("./useAuthSession");
|
|
11
|
-
const useIsTmg = ()
|
|
11
|
+
const useIsTmg = exports.useIsTmg = function useIsTmg() {
|
|
12
|
+
let internal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
12
13
|
const {
|
|
13
14
|
branchTypes
|
|
14
|
-
} = (0, _queries.useBranchTypes)();
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
} = (0, _useAuthSession.useAuthSession)();
|
|
15
|
+
} = (0, _queries.useBranchTypes)() || {};
|
|
16
|
+
const session = (0, _useAuthSession.useAuthSession)();
|
|
17
|
+
const branch = session === null || session === void 0 ? void 0 : session.branch;
|
|
18
18
|
return (0, _react.useMemo)(() => {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (!internal || !(branchTypes !== null && branchTypes !== void 0 && branchTypes.byId) || !(branch !== null && branch !== void 0 && branch.organisatietype)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const branchType = branchTypes.byId[branch.organisatietype];
|
|
21
23
|
return (branchType === null || branchType === void 0 ? void 0 : branchType.title) === _constants__.TMG_ORGANIZATION_TYPE;
|
|
22
|
-
}, [branchTypes, branch]);
|
|
23
|
-
};
|
|
24
|
-
exports.useIsTmg = useIsTmg;
|
|
24
|
+
}, [branchTypes, branch, internal]);
|
|
25
|
+
};
|