thm-p3-configurator 0.0.32 → 0.0.35

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.
@@ -50,13 +50,16 @@ const LicensePlateInput = _ref => {
50
50
  onChange = () => {},
51
51
  onSubmit = () => {}
52
52
  } = _ref;
53
- const [value, setValue] = (0, _react.useState)(licensePlateValidator.init(initialValue));
53
+ const [value, setValue] = (0, _react.useState)(licensePlateValidator.init(initialValue) || '');
54
54
  const [isFocused, setIsFocused] = (0, _react.useState)(false);
55
55
  const handleChange = value => {
56
- const parsedLicensePlate = licensePlateValidator.init(value);
56
+ const parsedLicensePlate = licensePlateValidator.init(value) || '';
57
57
  setValue(parsedLicensePlate);
58
58
  onChange(parsedLicensePlate);
59
59
  };
60
+ (0, _react.useEffect)(() => {
61
+ handleChange(initialValue);
62
+ }, [initialValue]);
60
63
  const handleKeyDown = key => {
61
64
  if (isFocused) {
62
65
  setIsFocused(false);
@@ -128,7 +128,7 @@ const LocationList = _ref => {
128
128
  selectedBranch
129
129
  }] = (0, _OrderSessionContext.useOrderSession)();
130
130
  const selectedRef = (0, _react.useRef)(null);
131
- const locationsWithDistance = locationIds.map(locationId => {
131
+ const locationsWithDistance = locationIds.map((locationId, index) => {
132
132
  const location = locationsById[locationId];
133
133
  const coordinates = location.googleMapsLocation;
134
134
  if (!coordinates) return null;
@@ -123,7 +123,7 @@ const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
123
123
  }), franchiseName && /*#__PURE__*/_react.default.createElement("h6", {
124
124
  className: (0, _helpers__.withStyle)('my-2')
125
125
  }, "Keten: ", franchiseName), /*#__PURE__*/_react.default.createElement(_LocationList.default, {
126
- locationIds: visibleIds,
126
+ locationIds: allIds,
127
127
  locationsById: byId,
128
128
  userLocation: userLocation
129
129
  })))));
@@ -78,7 +78,7 @@ const LicensePlateForm = _ref => {
78
78
  } = (0, _reactRouter.useLocation)();
79
79
  const searchParams = new URLSearchParams(search);
80
80
  (0, _react.useEffect)(() => {
81
- initialValue && handleLicensePlateChange(initialValue);
81
+ handleLicensePlateChange(initialValue);
82
82
  }, [initialValue]);
83
83
  const handleManualSwitch = () => {
84
84
  history.push("/configurator/manual".concat(searchParams !== null && searchParams !== void 0 && searchParams.size ? "?".concat(searchParams.toString()) : '') // append search params if found
@@ -118,7 +118,7 @@ const LicensePlateForm = _ref => {
118
118
  className: (0, _helpers__.withStyle)('btn btn-primary'),
119
119
  type: "button",
120
120
  onClick: onSubmit,
121
- isDisabled: !licensePlate || licensePlate.length < 6,
121
+ isDisabled: !licensePlate || (licensePlate === null || licensePlate === void 0 ? void 0 : licensePlate.length) < 6,
122
122
  label: 'Volgende'
123
123
  })))));
124
124
  };
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.symbol.description.js");
3
4
  require("core-js/modules/es.array.includes.js");
5
+ require("core-js/modules/es.array.sort.js");
4
6
  require("core-js/modules/es.json.stringify.js");
5
7
  require("core-js/modules/es.string.includes.js");
6
8
  require("core-js/modules/es.weak-map.js");
@@ -11,7 +13,9 @@ Object.defineProperty(exports, "__esModule", {
11
13
  value: true
12
14
  });
13
15
  exports.default = void 0;
16
+ require("core-js/modules/es.symbol.description.js");
14
17
  require("core-js/modules/es.array.includes.js");
18
+ require("core-js/modules/es.array.sort.js");
15
19
  require("core-js/modules/es.json.stringify.js");
16
20
  require("core-js/modules/es.string.includes.js");
17
21
  require("core-js/modules/esnext.iterator.map.js");
@@ -173,8 +177,15 @@ const ProductsOverview = () => {
173
177
  return /*#__PURE__*/_react.default.createElement("div", {
174
178
  className: (0, _helpers__.withStyle)(index === 0 ? 'mt-0' : 'mt-5'),
175
179
  key: "category-".concat(productCategory)
176
- }, /*#__PURE__*/_react.default.createElement("h2", null, productCategory), productsPerCategory.map(product => {
180
+ }, /*#__PURE__*/_react.default.createElement("h2", null, productCategory), productsPerCategory.sort((a, b) => (0, _product.checkIfTowbarIsRecommended)({
181
+ product: a,
182
+ category: productCategory
183
+ }) ? -1 : 0).map(product => {
177
184
  var _product$images, _product$images2;
185
+ const isRecommended = (0, _product.checkIfTowbarIsRecommended)({
186
+ product,
187
+ category: productCategory
188
+ });
178
189
  if (productCategory === _constants__.PRODUCT_CATEGORIES.BOARD_COMPUTER && selectedCableset) {
179
190
  return /*#__PURE__*/_react.default.createElement(_BoardComputerCard.default, {
180
191
  defaultSelected: !isBoardComputerDeselected || selectedBoardComputer === product.articleNumber,
@@ -191,7 +202,7 @@ const ProductsOverview = () => {
191
202
  },
192
203
  key: product.articleNumber,
193
204
  id: product.articleNumber,
194
- description: "Bij deze auto is het noodzakelijk om de boordcomputer te updaten, zodat functies als ESP, \n parkeersensoren, mistlampuitschakeling, lane-assist, e.a. correct blijven werken.",
205
+ description: (0, _product.formatHyperDescription)(product === null || product === void 0 ? void 0 : product.description),
195
206
  title: product === null || product === void 0 ? void 0 : product.title,
196
207
  price: product === null || product === void 0 ? void 0 : product.price
197
208
  });
@@ -199,7 +210,7 @@ const ProductsOverview = () => {
199
210
  return /*#__PURE__*/_react.default.createElement(_ProductCard.default, {
200
211
  key: product.articleNumber,
201
212
  hasCheckbox: (productsPerCategory === null || productsPerCategory === void 0 ? void 0 : productsPerCategory.length) > 1,
202
- isRecommended: false,
213
+ isRecommended: isRecommended,
203
214
  productId: product === null || product === void 0 ? void 0 : product.articleNumber,
204
215
  productTitle: product === null || product === void 0 ? void 0 : product.title,
205
216
  productDescription: product === null || product === void 0 ? void 0 : product.productDescription,
@@ -64,20 +64,13 @@ const InternalBranchSelectorModal = () => {
64
64
  myBranchesError
65
65
  } = (0, _queries.useMyBranches)(formula);
66
66
  const [{
67
- selectedBranch
67
+ selectedBranch,
68
+ existingDossierId
68
69
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
69
- const handlePrimaryButtonClicked = () => {
70
- dispatch({
71
- type: _OrderSessionContext.orderSessionActions.SET_SELECTED_BRANCH,
72
- payload: {
73
- branchId: _selectedBranchId
74
- }
75
- });
76
- };
77
70
  (0, _react.useEffect)(() => {
78
71
  var _branchTypes$byId$aut, _authSession$branch, _myBranches$;
79
72
  // If it's a TMG group, do nothing
80
- if ((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) {
73
+ if (existingDossierId || (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) {
81
74
  return;
82
75
  }
83
76
 
@@ -93,7 +86,15 @@ const InternalBranchSelectorModal = () => {
93
86
  branchId: myBranches === null || myBranches === void 0 || (_myBranches$ = myBranches[0]) === null || _myBranches$ === void 0 ? void 0 : _myBranches$.entityId
94
87
  }
95
88
  });
96
- }, [selectedBranch, myBranches, branchTypes, authSession]);
89
+ }, [selectedBranch, myBranches, branchTypes, authSession, existingDossierId]);
90
+ const handlePrimaryButtonClicked = () => {
91
+ dispatch({
92
+ type: _OrderSessionContext.orderSessionActions.SET_SELECTED_BRANCH,
93
+ payload: {
94
+ branchId: _selectedBranchId
95
+ }
96
+ });
97
+ };
97
98
  if (isLoadingBranchTypes) {
98
99
  return /*#__PURE__*/_react.default.createElement("div", {
99
100
  className: "thm-configurator-wrapper--offset"
@@ -101,7 +102,7 @@ const InternalBranchSelectorModal = () => {
101
102
  }
102
103
 
103
104
  // Note: if the current formula is TowMotive Group, do not show the modal (the branch selection happens on the step before the appointment)
104
- if ((branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut2 = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch2 = authSession.branch) === null || _authSession$branch2 === void 0 || (_authSession$branch2 = _authSession$branch2.organisatietype) === null || _authSession$branch2 === void 0 ? void 0 : _authSession$branch2[0]]) === null || _branchTypes$byId$aut2 === void 0 ? void 0 : _branchTypes$byId$aut2.title) === _constants__.TMG_ORGANIZATION_TYPE) {
105
+ if (existingDossierId || (branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut2 = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch2 = authSession.branch) === null || _authSession$branch2 === void 0 || (_authSession$branch2 = _authSession$branch2.organisatietype) === null || _authSession$branch2 === void 0 ? void 0 : _authSession$branch2[0]]) === null || _branchTypes$byId$aut2 === void 0 ? void 0 : _branchTypes$byId$aut2.title) === _constants__.TMG_ORGANIZATION_TYPE) {
105
106
  return null;
106
107
  }
107
108
  return /*#__PURE__*/_react.default.createElement(_Modal.default, {
@@ -36,7 +36,7 @@ const InternalCancelDossierEdit = () => {
36
36
  shouldForceReset: true
37
37
  }
38
38
  });
39
- history.push('/configurator');
39
+ history.push('/dashboard');
40
40
  };
41
41
  if (!existingDossierId) return null;
42
42
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -125,6 +125,10 @@ const INITIAL_ORDER_SESSION_STATE = {
125
125
  },
126
126
  discountAmount: null,
127
127
  discountPercentage: null,
128
+ channel: {
129
+ channelId: null,
130
+ channelType: null
131
+ },
128
132
  appointment: {
129
133
  date: null,
130
134
  time: null,
@@ -74,8 +74,8 @@ const parseDossierToOrderSession = exports.parseDossierToOrderSession = function
74
74
  model: dossier !== null && dossier !== void 0 && dossier.kenteken ? null : dossier === null || dossier === void 0 ? void 0 : dossier.model,
75
75
  // Note: only fill in when license plate is empty
76
76
  channel: {
77
- id: dossier === null || dossier === void 0 || (_dossier$kanaal = dossier.kanaal) === null || _dossier$kanaal === void 0 ? void 0 : _dossier$kanaal.entityId,
78
- partnerId: dossier === null || dossier === void 0 || (_dossier$kanaalPartne = dossier.kanaalPartner) === null || _dossier$kanaalPartne === void 0 ? void 0 : _dossier$kanaalPartne.entityId
77
+ channelType: dossier === null || dossier === void 0 || (_dossier$kanaal = dossier.kanaal) === null || _dossier$kanaal === void 0 ? void 0 : _dossier$kanaal.entityId,
78
+ channelId: dossier === null || dossier === void 0 || (_dossier$kanaalPartne = dossier.kanaalPartner) === null || _dossier$kanaalPartne === void 0 ? void 0 : _dossier$kanaalPartne.entityId
79
79
  },
80
80
  durationAnswer: dossier === null || dossier === void 0 ? void 0 : dossier.looptijd,
81
81
  executionAnswer1: dossier === null || dossier === void 0 ? void 0 : dossier.uitvoeringTrekhaakExecuton1,
@@ -7,11 +7,12 @@ require("core-js/modules/es.string.includes.js");
7
7
  require("core-js/modules/esnext.iterator.constructor.js");
8
8
  require("core-js/modules/esnext.iterator.filter.js");
9
9
  require("core-js/modules/esnext.iterator.flat-map.js");
10
+ require("core-js/modules/esnext.iterator.map.js");
10
11
  require("core-js/modules/web.dom-collections.iterator.js");
11
12
  Object.defineProperty(exports, "__esModule", {
12
13
  value: true
13
14
  });
14
- exports.validateCartInput = exports.extractProductSpecsArray = void 0;
15
+ exports.validateCartInput = exports.formatHyperDescription = exports.extractProductSpecsArray = exports.checkIfTowbarIsRecommended = void 0;
15
16
  require("core-js/modules/es.array.flat-map.js");
16
17
  require("core-js/modules/es.array.includes.js");
17
18
  require("core-js/modules/es.array.unscopables.flat-map.js");
@@ -19,6 +20,7 @@ require("core-js/modules/es.string.includes.js");
19
20
  require("core-js/modules/esnext.iterator.constructor.js");
20
21
  require("core-js/modules/esnext.iterator.filter.js");
21
22
  require("core-js/modules/esnext.iterator.flat-map.js");
23
+ require("core-js/modules/esnext.iterator.map.js");
22
24
  require("core-js/modules/web.dom-collections.iterator.js");
23
25
  var _constants__ = require("../__constants__");
24
26
  /**
@@ -48,4 +50,25 @@ const validateCartInput = exports.validateCartInput = function validateCartInput
48
50
  return filteredCart;
49
51
  }
50
52
  return;
51
- };
53
+ };
54
+
55
+ /**
56
+ * @description Checks if a product is recommended, by checking if it both a towbar and is detachable
57
+ */
58
+ const checkIfTowbarIsRecommended = _ref3 => {
59
+ var _product$subgroupName;
60
+ let {
61
+ product,
62
+ category
63
+ } = _ref3;
64
+ return category === _constants__.PRODUCT_CATEGORIES.TOWBAR && ((product === null || product === void 0 ? void 0 : product.subgroupName.toLowerCase().includes('afneembaar')) || (product === null || product === void 0 || (_product$subgroupName = product.subgroupName) === null || _product$subgroupName === void 0 ? void 0 : _product$subgroupName.toLowerCase().includes('afneembare')));
65
+ };
66
+
67
+ /**
68
+ * @description Formats the description of a product
69
+ */
70
+ exports.checkIfTowbarIsRecommended = checkIfTowbarIsRecommended;
71
+ const formatHyperDescription = description => {
72
+ return description === null || description === void 0 ? void 0 : description.ops.map(phrase => phrase.insert).join('');
73
+ };
74
+ exports.formatHyperDescription = formatHyperDescription;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.32",
3
+ "version": "0.0.35",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",