thm-p3-configurator 0.0.153 → 0.0.155
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.
|
@@ -62,7 +62,7 @@ function _interopRequireWildcard(e, r) {
|
|
|
62
62
|
return n.default = e, t && t.set(e, n), n;
|
|
63
63
|
}
|
|
64
64
|
const ProductsOverview = () => {
|
|
65
|
-
var _products$
|
|
65
|
+
var _products$Trekhaak2, _products$Kabelset, _products$Combiset;
|
|
66
66
|
const isProductsInitialLoad = (0, _react.useRef)(true);
|
|
67
67
|
const formula = (0, _FormulaContext.useFormula)();
|
|
68
68
|
const isTmg = (0, _useIsTmg.useIsTmg)();
|
|
@@ -115,11 +115,36 @@ const ProductsOverview = () => {
|
|
|
115
115
|
priceCalculationDate,
|
|
116
116
|
skipFilters
|
|
117
117
|
});
|
|
118
|
+
(0, _react.useEffect)(() => {
|
|
119
|
+
var _products$Trekhaak;
|
|
120
|
+
// 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) {
|
|
122
|
+
var _products$PRODUCT_CAT;
|
|
123
|
+
const towbarId = products.Trekhaak[0].articleNumber;
|
|
124
|
+
dispatch({
|
|
125
|
+
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_TOWBAR,
|
|
126
|
+
payload: {
|
|
127
|
+
towbarId
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Auto-select kabelset if there's exactly one kabelset available (reusing existing logic)
|
|
132
|
+
if (!selectedCableset && ((_products$PRODUCT_CAT = products[_constants__.PRODUCT_CATEGORIES.CABLESET]) === null || _products$PRODUCT_CAT === void 0 ? void 0 : _products$PRODUCT_CAT.length) === 1) {
|
|
133
|
+
const kabelsetId = products[_constants__.PRODUCT_CATEGORIES.CABLESET][0].articleNumber;
|
|
134
|
+
dispatch({
|
|
135
|
+
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_CABLESET,
|
|
136
|
+
payload: {
|
|
137
|
+
cabelsetId: kabelsetId
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}, [isLoadingProducts, products, selectedTowbar, selectedCableset, dispatch]);
|
|
118
143
|
if (isLoadingProducts && isProductsInitialLoad.current === true) {
|
|
119
144
|
isProductsInitialLoad.current = false;
|
|
120
145
|
return /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null);
|
|
121
146
|
}
|
|
122
|
-
if (isProductsError || !isLoadingProducts && (!(products !== null && products !== void 0 && (_products$
|
|
147
|
+
if (isProductsError || !isLoadingProducts && (!(products !== null && products !== void 0 && (_products$Trekhaak2 = products.Trekhaak) !== null && _products$Trekhaak2 !== void 0 && _products$Trekhaak2.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)) {
|
|
123
148
|
return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
|
|
124
149
|
to: "/configurator/geen-producten"
|
|
125
150
|
});
|
|
@@ -151,9 +176,9 @@ const ProductsOverview = () => {
|
|
|
151
176
|
|
|
152
177
|
// Auto-select kabelset if towbar is selected and no kabelset is currently selected
|
|
153
178
|
if (isSelected && !selectedCableset) {
|
|
154
|
-
var _products$
|
|
179
|
+
var _products$PRODUCT_CAT2;
|
|
155
180
|
// Check if there's exactly one kabelset available
|
|
156
|
-
if (((_products$
|
|
181
|
+
if (((_products$PRODUCT_CAT2 = products[_constants__.PRODUCT_CATEGORIES.CABLESET]) === null || _products$PRODUCT_CAT2 === void 0 ? void 0 : _products$PRODUCT_CAT2.length) === 1) {
|
|
157
182
|
const kabelsetId = products[_constants__.PRODUCT_CATEGORIES.CABLESET][0].articleNumber;
|
|
158
183
|
dispatch({
|
|
159
184
|
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_CABLESET,
|