thm-p3-configurator 0.0.157 → 0.0.158
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.
|
@@ -4,6 +4,8 @@ require("core-js/modules/es.symbol.description.js");
|
|
|
4
4
|
require("core-js/modules/es.array.sort.js");
|
|
5
5
|
require("core-js/modules/es.json.stringify.js");
|
|
6
6
|
require("core-js/modules/es.weak-map.js");
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.find.js");
|
|
7
9
|
require("core-js/modules/esnext.iterator.map.js");
|
|
8
10
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
11
|
require("core-js/modules/es.weak-map.js");
|
|
@@ -14,6 +16,8 @@ exports.default = void 0;
|
|
|
14
16
|
require("core-js/modules/es.symbol.description.js");
|
|
15
17
|
require("core-js/modules/es.array.sort.js");
|
|
16
18
|
require("core-js/modules/es.json.stringify.js");
|
|
19
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
20
|
+
require("core-js/modules/esnext.iterator.find.js");
|
|
17
21
|
require("core-js/modules/esnext.iterator.map.js");
|
|
18
22
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
19
23
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -62,7 +66,7 @@ function _interopRequireWildcard(e, r) {
|
|
|
62
66
|
return n.default = e, t && t.set(e, n), n;
|
|
63
67
|
}
|
|
64
68
|
const ProductsOverview = () => {
|
|
65
|
-
var _products$
|
|
69
|
+
var _products$Trekhaak3, _products$Kabelset, _products$Combiset;
|
|
66
70
|
const isProductsInitialLoad = (0, _react.useRef)(true);
|
|
67
71
|
const formula = (0, _FormulaContext.useFormula)();
|
|
68
72
|
const isTmg = (0, _useIsTmg.useIsTmg)();
|
|
@@ -116,9 +120,9 @@ const ProductsOverview = () => {
|
|
|
116
120
|
skipFilters
|
|
117
121
|
});
|
|
118
122
|
(0, _react.useEffect)(() => {
|
|
119
|
-
var _products$Trekhaak;
|
|
123
|
+
var _products$Trekhaak, _products$Trekhaak2, _products$PRODUCT_CAT3;
|
|
120
124
|
// Only run this if we have products loaded and no towbar is currently selected
|
|
121
|
-
if (!isLoadingProducts && (products === null || products === void 0 || (_products$Trekhaak = products.Trekhaak) === null || _products$Trekhaak === void 0 ? void 0 : _products$Trekhaak.length) === 1 && !selectedTowbar) {
|
|
125
|
+
if (!isLoadingProducts && (products === null || products === void 0 || (_products$Trekhaak = products.Trekhaak) === null || _products$Trekhaak === void 0 ? void 0 : _products$Trekhaak.length) === 1 && !selectedTowbar && !selectedCombiset) {
|
|
122
126
|
var _products$PRODUCT_CAT;
|
|
123
127
|
const towbarId = products.Trekhaak[0].articleNumber;
|
|
124
128
|
dispatch({
|
|
@@ -139,12 +143,53 @@ const ProductsOverview = () => {
|
|
|
139
143
|
});
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
|
-
|
|
146
|
+
// If we have multiple towbars, pre-select the recommended one if no other is selected
|
|
147
|
+
else if (!isLoadingProducts && (products === null || products === void 0 || (_products$Trekhaak2 = products.Trekhaak) === null || _products$Trekhaak2 === void 0 ? void 0 : _products$Trekhaak2.length) > 1 && !selectedTowbar && !selectedCombiset) {
|
|
148
|
+
// Find the recommended towbar
|
|
149
|
+
const recommendedTowbar = products.Trekhaak.find(product => (0, _product.checkIfTowbarIsRecommended)({
|
|
150
|
+
product,
|
|
151
|
+
category: _constants__.PRODUCT_CATEGORIES.TOWBAR
|
|
152
|
+
}));
|
|
153
|
+
|
|
154
|
+
// If there's a recommended towbar, select it
|
|
155
|
+
if (recommendedTowbar) {
|
|
156
|
+
var _products$PRODUCT_CAT2;
|
|
157
|
+
dispatch({
|
|
158
|
+
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_TOWBAR,
|
|
159
|
+
payload: {
|
|
160
|
+
towbarId: recommendedTowbar.articleNumber
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Auto-select kabelset if no kabelset is currently selected
|
|
165
|
+
if (!selectedCableset && ((_products$PRODUCT_CAT2 = products[_constants__.PRODUCT_CATEGORIES.CABLESET]) === null || _products$PRODUCT_CAT2 === void 0 ? void 0 : _products$PRODUCT_CAT2.length) === 1) {
|
|
166
|
+
const kabelsetId = products[_constants__.PRODUCT_CATEGORIES.CABLESET][0].articleNumber;
|
|
167
|
+
dispatch({
|
|
168
|
+
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_CABLESET,
|
|
169
|
+
payload: {
|
|
170
|
+
cabelsetId: kabelsetId
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Auto-select boardcomputer if one is available and none is currently selected
|
|
178
|
+
if (!isLoadingProducts && (products === null || products === void 0 || (_products$PRODUCT_CAT3 = products[_constants__.PRODUCT_CATEGORIES.BOARD_COMPUTER]) === null || _products$PRODUCT_CAT3 === void 0 ? void 0 : _products$PRODUCT_CAT3.length) > 0 && !selectedBoardComputer && !isBoardComputerDeselected) {
|
|
179
|
+
const boardComputerId = products[_constants__.PRODUCT_CATEGORIES.BOARD_COMPUTER][0].articleNumber;
|
|
180
|
+
dispatch({
|
|
181
|
+
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_BOARDCOMPUTER,
|
|
182
|
+
payload: {
|
|
183
|
+
id: boardComputerId
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}, [isLoadingProducts, products, selectedTowbar, selectedCableset, selectedBoardComputer, isBoardComputerDeselected, dispatch]);
|
|
143
188
|
if (isLoadingProducts && isProductsInitialLoad.current === true) {
|
|
144
189
|
isProductsInitialLoad.current = false;
|
|
145
190
|
return /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null);
|
|
146
191
|
}
|
|
147
|
-
if (isProductsError || !isLoadingProducts && (!(products !== null && products !== void 0 && (_products$
|
|
192
|
+
if (isProductsError || !isLoadingProducts && (!(products !== null && products !== void 0 && (_products$Trekhaak3 = products.Trekhaak) !== null && _products$Trekhaak3 !== void 0 && _products$Trekhaak3.length) || !(products !== null && products !== void 0 && (_products$Kabelset = products.Kabelset) !== null && _products$Kabelset !== void 0 && _products$Kabelset.length)) && !(products !== null && products !== void 0 && (_products$Combiset = products.Combiset) !== null && _products$Combiset !== void 0 && _products$Combiset.length)) {
|
|
148
193
|
return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
|
|
149
194
|
to: "/configurator/geen-producten"
|
|
150
195
|
});
|
|
@@ -176,9 +221,9 @@ const ProductsOverview = () => {
|
|
|
176
221
|
|
|
177
222
|
// Auto-select kabelset if towbar is selected and no kabelset is currently selected
|
|
178
223
|
if (isSelected && !selectedCableset) {
|
|
179
|
-
var _products$
|
|
224
|
+
var _products$PRODUCT_CAT4;
|
|
180
225
|
// Check if there's exactly one kabelset available
|
|
181
|
-
if (((_products$
|
|
226
|
+
if (((_products$PRODUCT_CAT4 = products[_constants__.PRODUCT_CATEGORIES.CABLESET]) === null || _products$PRODUCT_CAT4 === void 0 ? void 0 : _products$PRODUCT_CAT4.length) === 1) {
|
|
182
227
|
const kabelsetId = products[_constants__.PRODUCT_CATEGORIES.CABLESET][0].articleNumber;
|
|
183
228
|
dispatch({
|
|
184
229
|
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_CABLESET,
|