thm-p3-configurator 0.0.156 → 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.
- package/dist/src/shared/__components__/ProductCard/ProductCardImage.js +3 -2
- package/dist/src/shared/__components__/ProductCard/index.js +4 -2
- package/dist/src/shared/__containers__/BoardComputerCard.js +4 -2
- package/dist/src/shared/__containers__/ProductsOverview.js +61 -12
- package/package.json +1 -1
|
@@ -13,14 +13,15 @@ function _interopRequireDefault(e) {
|
|
|
13
13
|
}
|
|
14
14
|
const ProductCardImage = _ref => {
|
|
15
15
|
let {
|
|
16
|
-
image
|
|
16
|
+
image,
|
|
17
|
+
isBoardComputer
|
|
17
18
|
} = _ref;
|
|
18
19
|
if (!image) {
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
21
22
|
return /*#__PURE__*/_react.default.createElement("img", {
|
|
22
23
|
src: image,
|
|
23
|
-
className: (0, _helpers__.withStyle)(
|
|
24
|
+
className: (0, _helpers__.withStyle)("card__image img-fluid ".concat(isBoardComputer ? 'mb-2' : '')),
|
|
24
25
|
alt: "product afbeelding"
|
|
25
26
|
});
|
|
26
27
|
};
|
|
@@ -74,7 +74,8 @@ const ProductCard = _ref => {
|
|
|
74
74
|
onSelect = () => {},
|
|
75
75
|
isOnlyProductInCategory = false,
|
|
76
76
|
isAnotherProductSelected = true,
|
|
77
|
-
isTmg = false
|
|
77
|
+
isTmg = false,
|
|
78
|
+
isBoardComputer = false
|
|
78
79
|
} = _ref;
|
|
79
80
|
const [isSelected, setIsSelected] = (0, _react.useState)(defaultSelected);
|
|
80
81
|
const {
|
|
@@ -114,7 +115,8 @@ const ProductCard = _ref => {
|
|
|
114
115
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
115
116
|
className: (0, _helpers__.withStyle)('col-md-4 d-flex justify-content-center position-relative')
|
|
116
117
|
}, /*#__PURE__*/_react.default.createElement(_ProductCardImage.default, {
|
|
117
|
-
image: productImage
|
|
118
|
+
image: productImage,
|
|
119
|
+
isBoardComputer: isBoardComputer
|
|
118
120
|
}), /*#__PURE__*/_react.default.createElement(_ProductCardDiscountAlert.default, {
|
|
119
121
|
label: productDiscountedLabel,
|
|
120
122
|
price: productPrice,
|
|
@@ -51,6 +51,7 @@ const BoardComputerCard = _ref => {
|
|
|
51
51
|
description,
|
|
52
52
|
title,
|
|
53
53
|
price,
|
|
54
|
+
productImage,
|
|
54
55
|
onSelect = _ref2 => {
|
|
55
56
|
let {
|
|
56
57
|
isSelected,
|
|
@@ -102,7 +103,7 @@ const BoardComputerCard = _ref => {
|
|
|
102
103
|
productTitle: title,
|
|
103
104
|
productDescription: description,
|
|
104
105
|
productUsps: [],
|
|
105
|
-
productImage:
|
|
106
|
+
productImage: productImage,
|
|
106
107
|
isDisabled: false,
|
|
107
108
|
defaultSelected: isSelected,
|
|
108
109
|
onSelect: handleSelect,
|
|
@@ -111,7 +112,8 @@ const BoardComputerCard = _ref => {
|
|
|
111
112
|
productSpecifications: [],
|
|
112
113
|
showPrice: APP_CONFIG.internal,
|
|
113
114
|
canUnselect: canUnselect,
|
|
114
|
-
isOnlyProductInCategory: isSelected
|
|
115
|
+
isOnlyProductInCategory: isSelected,
|
|
116
|
+
isBoardComputer: true
|
|
115
117
|
}), anchorEl && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_Modal.default, {
|
|
116
118
|
isOpen: isModalOpen,
|
|
117
119
|
size: "large",
|
|
@@ -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,
|
|
@@ -276,11 +321,16 @@ const ProductsOverview = () => {
|
|
|
276
321
|
product: a,
|
|
277
322
|
category: productCategory
|
|
278
323
|
}) ? -1 : 0).map(product => {
|
|
279
|
-
var _product$
|
|
324
|
+
var _product$images, _product$images2, _product$locationPric;
|
|
280
325
|
const isRecommended = (0, _product.checkIfTowbarIsRecommended)({
|
|
281
326
|
product,
|
|
282
327
|
category: productCategory
|
|
283
328
|
});
|
|
329
|
+
|
|
330
|
+
// Generate the product image URL
|
|
331
|
+
const productImageUrl = product !== null && product !== void 0 && (_product$images = product.images) !== null && _product$images !== void 0 && _product$images[0] ? (0, _image.getImageFromHyper)({
|
|
332
|
+
imageId: product === null || product === void 0 || (_product$images2 = product.images) === null || _product$images2 === void 0 ? void 0 : _product$images2[0]
|
|
333
|
+
}) : _logoPrimary.default;
|
|
284
334
|
if (productCategory === _constants__.PRODUCT_CATEGORIES.BOARD_COMPUTER && selectedCableset) {
|
|
285
335
|
return /*#__PURE__*/_react.default.createElement(_BoardComputerCard.default, {
|
|
286
336
|
defaultSelected: selectedBoardComputer === product.articleNumber,
|
|
@@ -299,7 +349,8 @@ const ProductsOverview = () => {
|
|
|
299
349
|
id: product.articleNumber,
|
|
300
350
|
description: (0, _product.formatHyperDescription)(product === null || product === void 0 ? void 0 : product.description),
|
|
301
351
|
title: product === null || product === void 0 ? void 0 : product.subgroupName,
|
|
302
|
-
price: product === null || product === void 0 ? void 0 : product.price
|
|
352
|
+
price: product === null || product === void 0 ? void 0 : product.price,
|
|
353
|
+
productImage: productImageUrl
|
|
303
354
|
});
|
|
304
355
|
}
|
|
305
356
|
return /*#__PURE__*/_react.default.createElement(_ProductCard.default, {
|
|
@@ -321,9 +372,7 @@ const ProductsOverview = () => {
|
|
|
321
372
|
type: 'remark',
|
|
322
373
|
text: product === null || product === void 0 ? void 0 : product.remark
|
|
323
374
|
}],
|
|
324
|
-
productImage:
|
|
325
|
-
imageId: product === null || product === void 0 || (_product$images2 = product.images) === null || _product$images2 === void 0 ? void 0 : _product$images2[0]
|
|
326
|
-
}) : _logoPrimary.default,
|
|
375
|
+
productImage: productImageUrl,
|
|
327
376
|
isDisabled: false,
|
|
328
377
|
defaultSelected: productCategory === _constants__.PRODUCT_CATEGORIES.TOWBAR && selectedTowbar === product.articleNumber || productCategory === _constants__.PRODUCT_CATEGORIES.CABLESET && selectedCableset === product.articleNumber || productCategory === _constants__.PRODUCT_CATEGORIES.COMBISET && selectedCombiset === product.articleNumber
|
|
329
378
|
// Set both to false to prevent auto-selection when navigating back
|