thm-p3-configurator 0.0.147 → 0.0.149

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.
@@ -12,6 +12,8 @@ require("core-js/modules/esnext.iterator.map.js");
12
12
  require("core-js/modules/web.dom-collections.iterator.js");
13
13
  var _react = _interopRequireWildcard(require("react"));
14
14
  var _reactRouterDom = require("react-router-dom");
15
+ var _constants__ = require("../__constants__");
16
+ var _OrderSessionContext = require("../__context__/OrderSessionContext");
15
17
  var _helpers__ = require("../__helpers__");
16
18
  function _getRequireWildcardCache(e) {
17
19
  if ("function" != typeof WeakMap) return null;
@@ -47,6 +49,14 @@ const NavigationSteps = _ref => {
47
49
  onClick = () => {}
48
50
  } = _ref;
49
51
  const [stepNumber, setStepNumber] = (0, _react.useState)(defaultActiveStep);
52
+ const [{
53
+ selectedCableset,
54
+ selectedTowbar,
55
+ selectedCombiset,
56
+ currentDossierType,
57
+ existingDossierType,
58
+ selectedBranch
59
+ }] = (0, _OrderSessionContext.useOrderSession)();
50
60
  const handleClick = _ref2 => {
51
61
  let {
52
62
  to,
@@ -60,6 +70,16 @@ const NavigationSteps = _ref => {
60
70
  stepNumber
61
71
  });
62
72
  };
73
+ const currentType = currentDossierType || existingDossierType || _constants__.DOSSIER_TYPES.PlannedAppointment;
74
+ const hasCableSetAndTowbar = selectedCableset && selectedTowbar || selectedCombiset;
75
+ const isStepDisabled = index => {
76
+ if (index >= 0 && index <= 2) return !hasCableSetAndTowbar;
77
+ if (index === 3) {
78
+ const needsBranch = currentType === _constants__.DOSSIER_TYPES.PlannedAppointment || currentType === _constants__.DOSSIER_TYPES.AppointmentRequest;
79
+ return !hasCableSetAndTowbar || needsBranch && !selectedBranch;
80
+ }
81
+ return false;
82
+ };
63
83
  return /*#__PURE__*/_react.default.createElement("div", {
64
84
  className: (0, _helpers__.withStyle)('col-12')
65
85
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -74,7 +94,7 @@ const NavigationSteps = _ref => {
74
94
  } = _ref3;
75
95
  return /*#__PURE__*/_react.default.createElement(_reactRouterDom.NavLink, {
76
96
  key: title,
77
- className: "".concat((0, _helpers__.withStyle)('btn'), " ").concat(isEveryStepActive || stepNumber >= index ? (0, _helpers__.withStyle)('active') : '', " ").concat(index > 0 && isNavigationDisabled ? (0, _helpers__.withStyle)('disabled') : '', " "),
97
+ className: "".concat((0, _helpers__.withStyle)('btn'), " ").concat(isEveryStepActive || stepNumber >= index ? (0, _helpers__.withStyle)('active') : '', " ").concat(index > stepNumber && isStepDisabled(index) || index > 0 && isNavigationDisabled ? (0, _helpers__.withStyle)('disabled') : ''),
78
98
  onClick: () => handleClick({
79
99
  to,
80
100
  title,
@@ -12,7 +12,6 @@ require("core-js/modules/esnext.iterator.map.js");
12
12
  require("core-js/modules/web.dom-collections.iterator.js");
13
13
  var _react = _interopRequireWildcard(require("react"));
14
14
  var _queries = require("../../__api__/queries");
15
- var _constants__ = require("../../__constants__");
16
15
  var _helpers__ = require("../../__helpers__");
17
16
  var _ProductCardCheckbox = _interopRequireDefault(require("./ProductCardCheckbox"));
18
17
  var _ProductCardDescription = _interopRequireDefault(require("./ProductCardDescription"));
@@ -22,6 +21,7 @@ var _ProductCardPrice = _interopRequireDefault(require("./ProductCardPrice"));
22
21
  var _ProductCardRibbon = _interopRequireDefault(require("./ProductCardRibbon"));
23
22
  var _ProductCardSpecifications = _interopRequireDefault(require("./ProductCardSpecifications"));
24
23
  var _ProductCardUsps = _interopRequireDefault(require("./ProductCardUsps"));
24
+ var _constants__ = require("../../__constants__");
25
25
  function _interopRequireDefault(e) {
26
26
  return e && e.__esModule ? e : {
27
27
  default: e
@@ -98,12 +98,10 @@ const ProductCard = _ref => {
98
98
  setIsSelected(defaultSelected);
99
99
  }, [defaultSelected]);
100
100
  (0, _react.useEffect)(() => {
101
- // Only auto-select if it's the only product in the category
102
- // Remove auto-selection of recommended products when there are multiple products
103
- if (isOnlyProductInCategory) {
101
+ if (isOnlyProductInCategory || !isAnotherProductSelected && isRecommended) {
104
102
  handleSelected(true);
105
103
  }
106
- }, [isOnlyProductInCategory]);
104
+ }, [isOnlyProductInCategory, isRecommended]);
107
105
  return /*#__PURE__*/_react.default.createElement("div", {
108
106
  key: productId,
109
107
  className: (0, _helpers__.withStyle)("card card__horizontal card__link ".concat(isSelected ? 'active' : '', " container-fluid g-0")),
@@ -141,6 +141,15 @@ const ProductsOverview = () => {
141
141
  switch (productCategory) {
142
142
  case _constants__.PRODUCT_CATEGORIES.TOWBAR:
143
143
  {
144
+ // When selecting a towbar, deselect any combiset
145
+ if (isSelected && selectedCombiset) {
146
+ dispatch({
147
+ type: _OrderSessionContext.orderSessionActions.SET_SELECTED_COMBISET,
148
+ payload: {
149
+ combisetId: null
150
+ }
151
+ });
152
+ }
144
153
  dispatch({
145
154
  type: _OrderSessionContext.orderSessionActions.SET_SELECTED_TOWBAR,
146
155
  payload: {
@@ -151,6 +160,15 @@ const ProductsOverview = () => {
151
160
  }
152
161
  case _constants__.PRODUCT_CATEGORIES.CABLESET:
153
162
  {
163
+ // When selecting a cableset, deselect any combiset
164
+ if (isSelected && selectedCombiset) {
165
+ dispatch({
166
+ type: _OrderSessionContext.orderSessionActions.SET_SELECTED_COMBISET,
167
+ payload: {
168
+ combisetId: null
169
+ }
170
+ });
171
+ }
154
172
  dispatch({
155
173
  type: _OrderSessionContext.orderSessionActions.SET_SELECTED_CABLESET,
156
174
  payload: {
@@ -161,6 +179,25 @@ const ProductsOverview = () => {
161
179
  }
162
180
  case _constants__.PRODUCT_CATEGORIES.COMBISET:
163
181
  {
182
+ // When selecting a combiset, deselect any towbar and cableset
183
+ if (isSelected) {
184
+ if (selectedTowbar) {
185
+ dispatch({
186
+ type: _OrderSessionContext.orderSessionActions.SET_SELECTED_TOWBAR,
187
+ payload: {
188
+ towbarId: null
189
+ }
190
+ });
191
+ }
192
+ if (selectedCableset) {
193
+ dispatch({
194
+ type: _OrderSessionContext.orderSessionActions.SET_SELECTED_CABLESET,
195
+ payload: {
196
+ cabelsetId: null
197
+ }
198
+ });
199
+ }
200
+ }
164
201
  dispatch({
165
202
  type: _OrderSessionContext.orderSessionActions.SET_SELECTED_COMBISET,
166
203
  payload: {
@@ -188,6 +225,7 @@ const ProductsOverview = () => {
188
225
 
189
226
  // Filter out Extras category from products object
190
227
  delete products[_constants__.PRODUCT_CATEGORIES.EXTRAS];
228
+ console.log(selectedBoardComputer, selectedCableset, selectedCombiset, selectedTowbar);
191
229
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isTmg && /*#__PURE__*/_react.default.createElement(_CheckboxInput.default, {
192
230
  name: 'skipFilters',
193
231
  initialValue: skipFilters,
@@ -217,7 +255,7 @@ const ProductsOverview = () => {
217
255
  const isAnotherProductSelected = productsPerCategory.some(otherProduct => [selectedCableset, selectedCombiset, selectedTowbar].includes(otherProduct.articleNumber) && otherProduct.articleNumber !== product.articleNumber);
218
256
  if (productCategory === _constants__.PRODUCT_CATEGORIES.BOARD_COMPUTER && selectedCableset) {
219
257
  return /*#__PURE__*/_react.default.createElement(_BoardComputerCard.default, {
220
- defaultSelected: !isBoardComputerDeselected || selectedBoardComputer === product.articleNumber,
258
+ defaultSelected: selectedBoardComputer === product.articleNumber,
221
259
  onSelect: _ref4 => {
222
260
  let {
223
261
  productId,
@@ -236,9 +274,6 @@ const ProductsOverview = () => {
236
274
  price: product === null || product === void 0 ? void 0 : product.price
237
275
  });
238
276
  }
239
-
240
- // Only preselect when it's the only product in its category
241
- const shouldPreselect = productsPerCategory.length === 1;
242
277
  return /*#__PURE__*/_react.default.createElement(_ProductCard.default, {
243
278
  isTmg: isTmg,
244
279
  stock: product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.stock,
@@ -262,9 +297,9 @@ const ProductsOverview = () => {
262
297
  imageId: product === null || product === void 0 || (_product$images2 = product.images) === null || _product$images2 === void 0 ? void 0 : _product$images2[0]
263
298
  }) : _logoPrimary.default,
264
299
  isDisabled: false,
265
- defaultSelected: [selectedCableset, selectedCombiset, selectedTowbar].includes(product.articleNumber),
300
+ 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,
266
301
  isAnotherProductSelected: isAnotherProductSelected,
267
- isOnlyProductInCategory: shouldPreselect,
302
+ isOnlyProductInCategory: false,
268
303
  onSelect: _ref5 => {
269
304
  let {
270
305
  productId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.147",
3
+ "version": "0.0.149",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",