thm-p3-configurator 0.0.53 → 0.0.55

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.
@@ -56,6 +56,7 @@ function _interopRequireWildcard(e, r) {
56
56
  return n.default = e, t && t.set(e, n), n;
57
57
  }
58
58
  const LicensePlateForm = _ref => {
59
+ var _ref2;
59
60
  let {
60
61
  initialValue,
61
62
  onSubmit,
@@ -66,6 +67,7 @@ const LicensePlateForm = _ref => {
66
67
  licensePlate,
67
68
  discountCode
68
69
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
70
+ const [filterLicensePlate, setFilterLicensePlate] = (0, _react.useState)(initialValue || '');
69
71
  const history = (0, _reactRouter.useHistory)();
70
72
  const formula = (0, _FormulaContext.useFormula)();
71
73
  if (!isFilter) {
@@ -85,22 +87,25 @@ const LicensePlateForm = _ref => {
85
87
  }, [initialValue]);
86
88
  const handleManualSwitch = () => {
87
89
  if (!isFilter) {
88
- history.push("/configurator/manual".concat(searchParams !== null && searchParams !== void 0 && searchParams.size ? "?".concat(searchParams.toString()) : '') // append search params if found
89
- );
90
+ history.push("/configurator/manual".concat(searchParams !== null && searchParams !== void 0 && searchParams.size ? "?".concat(searchParams.toString()) : ''));
90
91
  } else {
91
92
  filterModalChange(1);
92
93
  }
93
94
  };
94
95
  const handleLicensePlateChange = value => {
95
- dispatch({
96
- type: _OrderSessionContext.orderSessionActions.SET_LICENSE_PLATE,
97
- payload: {
98
- licensePlate: value
99
- }
100
- });
96
+ if (!isFilter) {
97
+ dispatch({
98
+ type: _OrderSessionContext.orderSessionActions.SET_LICENSE_PLATE,
99
+ payload: {
100
+ licensePlate: value
101
+ }
102
+ });
103
+ } else {
104
+ setFilterLicensePlate(value);
105
+ }
101
106
  };
102
107
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_LicensePlateInput.default, {
103
- initialValue: licensePlate,
108
+ initialValue: isFilter ? (_ref2 = filterLicensePlate !== null && filterLicensePlate !== void 0 ? filterLicensePlate : licensePlate) !== null && _ref2 !== void 0 ? _ref2 : '' : licensePlate !== null && licensePlate !== void 0 ? licensePlate : '',
104
109
  isReadOnly: false,
105
110
  onChange: handleLicensePlateChange,
106
111
  onSubmit: onSubmit
@@ -124,9 +129,12 @@ const LicensePlateForm = _ref => {
124
129
  }, /*#__PURE__*/_react.default.createElement(_PrimaryButton.default, {
125
130
  className: (0, _helpers__.withStyle)('btn btn-primary'),
126
131
  type: "button",
127
- onClick: onSubmit,
128
- isDisabled: !licensePlate || (licensePlate === null || licensePlate === void 0 ? void 0 : licensePlate.length) < 6,
129
- label: isFilter ? 'Sluiten' : 'Volgende'
132
+ onClick: () => onSubmit(isFilter ? {
133
+ value: filterLicensePlate,
134
+ type: 'licenseplate'
135
+ } : undefined),
136
+ isDisabled: !isFilter ? !licensePlate || licensePlate.length < 6 : false,
137
+ label: isFilter ? 'Filteren' : 'Volgende'
130
138
  })))));
131
139
  };
132
140
  var _default = exports.default = LicensePlateForm;
@@ -56,11 +56,11 @@ function _interopRequireWildcard(e, r) {
56
56
  return n.default = e, t && t.set(e, n), n;
57
57
  }
58
58
  const ManualSelectionForm = _ref => {
59
+ var _initialValues$model;
59
60
  let {
60
61
  onSubmit,
61
62
  initialValues = null,
62
63
  isFilter = false,
63
- handleSelectedFilterChange = () => {},
64
64
  filterModalChange = () => {}
65
65
  } = _ref;
66
66
  const [{
@@ -69,6 +69,7 @@ const ManualSelectionForm = _ref => {
69
69
  buildYear,
70
70
  discountCode
71
71
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
72
+ const [filterModel, setFilterModel] = (0, _react.useState)((_initialValues$model = initialValues === null || initialValues === void 0 ? void 0 : initialValues.model) !== null && _initialValues$model !== void 0 ? _initialValues$model : model);
72
73
  const {
73
74
  brands,
74
75
  isLoadingBrands
@@ -128,14 +129,15 @@ const ManualSelectionForm = _ref => {
128
129
  });
129
130
  };
130
131
  const handleModelChange = modelOption => {
131
- dispatch({
132
- type: _OrderSessionContext.orderSessionActions.SET_MODEL,
133
- payload: {
134
- model: modelOption.value
135
- }
136
- });
137
- if (isFilter) {
138
- handleSelectedFilterChange('model', modelOption.value);
132
+ if (!isFilter) {
133
+ dispatch({
134
+ type: _OrderSessionContext.orderSessionActions.SET_MODEL,
135
+ payload: {
136
+ model: modelOption.value
137
+ }
138
+ });
139
+ } else {
140
+ setFilterModel(modelOption.value);
139
141
  }
140
142
  };
141
143
  const handleBuildYearChange = buildYearOption => {
@@ -189,7 +191,10 @@ const ManualSelectionForm = _ref => {
189
191
  noOptionsMessage: "Geen opties beschikbaar",
190
192
  placeholder: "Maak een keuze",
191
193
  onChange: handleModelChange,
192
- initialValue: !model ? {
194
+ initialValue: isFilter ? {
195
+ value: filterModel,
196
+ label: filterModel
197
+ } : !model ? {
193
198
  value: initialValues === null || initialValues === void 0 ? void 0 : initialValues.model,
194
199
  label: initialValues === null || initialValues === void 0 ? void 0 : initialValues.model
195
200
  } : {
@@ -213,8 +218,11 @@ const ManualSelectionForm = _ref => {
213
218
  }, /*#__PURE__*/_react.default.createElement(_PrimaryButton.default, {
214
219
  className: (0, _helpers__.withStyle)('btn btn-primary'),
215
220
  type: "button",
216
- onClick: onSubmit,
217
- isDisabled: !model,
221
+ onClick: () => onSubmit(isFilter ? {
222
+ value: filterModel,
223
+ type: 'model'
224
+ } : undefined),
225
+ isDisabled: !model && !isFilter,
218
226
  label: isFilter ? 'Filter' : 'Sluiten'
219
227
  })))));
220
228
  };
@@ -124,7 +124,7 @@ const InternalBranchSelectorModal = () => {
124
124
  className: "thm-configurator-wrapper--offset"
125
125
  }, ' ', /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null), ' ');
126
126
  }
127
- const shouldShowModal = APP_CONFIG.internal && !selectedBranch && (isSingleOrderPage ? !existingDossierId : !existingDossierId && !isTMGOrganization);
127
+ const shouldShowModal = APP_CONFIG.internal && !selectedBranch && !existingDossierId && isTMGOrganization;
128
128
  return /*#__PURE__*/_react.default.createElement(_Modal.default, {
129
129
  isOpen: shouldShowModal,
130
130
  title: 'Kies een vestiging:',
@@ -63,8 +63,8 @@ function InternalLicenseplateModal(_ref) {
63
63
  onSubmit: onSubmit,
64
64
  isFilter: true
65
65
  }), activeModalType === 1 && /*#__PURE__*/_react.default.createElement(_ManualSelectionForm.default, {
66
- handleSelectedFilterChange: handleSelectedFilterChange,
67
66
  filterModalChange: handleModalTypeChange,
67
+ handleSelectedFilterChange: handleSelectedFilterChange,
68
68
  onSubmit: onSubmit,
69
69
  isFilter: true
70
70
  })));
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.symbol.description.js");
4
+ require("core-js/modules/es.array.flat-map.js");
5
+ require("core-js/modules/es.array.unscopables.flat-map.js");
4
6
  require("core-js/modules/es.json.stringify.js");
5
7
  require("core-js/modules/es.object.from-entries.js");
6
8
  require("core-js/modules/es.promise.js");
@@ -8,6 +10,7 @@ require("core-js/modules/es.regexp.to-string.js");
8
10
  require("core-js/modules/esnext.iterator.constructor.js");
9
11
  require("core-js/modules/esnext.iterator.filter.js");
10
12
  require("core-js/modules/esnext.iterator.find.js");
13
+ require("core-js/modules/esnext.iterator.flat-map.js");
11
14
  require("core-js/modules/esnext.iterator.for-each.js");
12
15
  require("core-js/modules/esnext.iterator.map.js");
13
16
  require("core-js/modules/web.dom-collections.iterator.js");
@@ -18,6 +21,8 @@ Object.defineProperty(exports, "__esModule", {
18
21
  });
19
22
  exports.fetchArticlesByLicensePlateAndModel = exports.fetchArticlesByFilters = exports.fetchArticlesByArticleNumbers = exports.enrichArticlesWithBrandsAndPrices = void 0;
20
23
  require("core-js/modules/es.symbol.description.js");
24
+ require("core-js/modules/es.array.flat-map.js");
25
+ require("core-js/modules/es.array.unscopables.flat-map.js");
21
26
  require("core-js/modules/es.json.stringify.js");
22
27
  require("core-js/modules/es.object.from-entries.js");
23
28
  require("core-js/modules/es.promise.js");
@@ -25,6 +30,7 @@ require("core-js/modules/es.regexp.to-string.js");
25
30
  require("core-js/modules/esnext.iterator.constructor.js");
26
31
  require("core-js/modules/esnext.iterator.filter.js");
27
32
  require("core-js/modules/esnext.iterator.find.js");
33
+ require("core-js/modules/esnext.iterator.flat-map.js");
28
34
  require("core-js/modules/esnext.iterator.map.js");
29
35
  require("core-js/modules/web.dom-collections.iterator.js");
30
36
  require("core-js/modules/web.url-search-params.js");
@@ -108,7 +114,7 @@ const fetchArticlesByFilters = async filters => {
108
114
  */
109
115
  exports.fetchArticlesByFilters = fetchArticlesByFilters;
110
116
  const fetchArticlesByLicensePlateAndModel = async (filters, formula, branchId) => {
111
- var _orderData$data, _orderData$data$data$;
117
+ var _orderData$data;
112
118
  const queryString = new URLSearchParams((0, _index.removeNullishProps)({
113
119
  formula,
114
120
  branchId,
@@ -123,7 +129,8 @@ const fetchArticlesByLicensePlateAndModel = async (filters, formula, branchId) =
123
129
  totalCount: 0
124
130
  };
125
131
  }
126
- const modelArticles = (_orderData$data$data$ = orderData.data.data.articles.extras) === null || _orderData$data$data$ === void 0 ? void 0 : _orderData$data$data$.map(formatModelArticle);
132
+ const articleArrays = Object.values(orderData.data.data.articles).filter(Array.isArray);
133
+ const modelArticles = articleArrays.flatMap(articles => articles.map(formatModelArticle));
127
134
  return {
128
135
  articles: modelArticles,
129
136
  totalCount: modelArticles.length
@@ -195,10 +202,10 @@ const enrichArticlesWithBrandsAndPrices = async (articles, branchId, formula) =>
195
202
  };
196
203
  exports.enrichArticlesWithBrandsAndPrices = enrichArticlesWithBrandsAndPrices;
197
204
  const formatModelArticle = article => {
198
- var _article$description$, _article$description, _article$boldDescript, _article$boldDescript2, _article$specificatio, _article$images, _article$images2, _article$articleNumbe;
205
+ var _ref, _article$name, _ref2, _article$description$, _article$description, _article$boldDescript, _article$boldDescript2, _article$specificatio, _article$images, _article$images2, _article$articleNumbe;
199
206
  return {
200
- name: article.name,
201
- description: (_article$description$ = article === null || article === void 0 || (_article$description = article.description) === null || _article$description === void 0 || (_article$description = _article$description.ops) === null || _article$description === void 0 || (_article$description = _article$description[0]) === null || _article$description === void 0 ? void 0 : _article$description.insert) !== null && _article$description$ !== void 0 ? _article$description$ : null,
207
+ name: (_ref = (_article$name = article.name) !== null && _article$name !== void 0 ? _article$name : article === null || article === void 0 ? void 0 : article.title) !== null && _ref !== void 0 ? _ref : null,
208
+ description: (_ref2 = (_article$description$ = article === null || article === void 0 || (_article$description = article.description) === null || _article$description === void 0 || (_article$description = _article$description.ops) === null || _article$description === void 0 || (_article$description = _article$description[0]) === null || _article$description === void 0 ? void 0 : _article$description.insert) !== null && _article$description$ !== void 0 ? _article$description$ : article === null || article === void 0 ? void 0 : article.remark) !== null && _ref2 !== void 0 ? _ref2 : null,
202
209
  subTitle: (_article$boldDescript = article === null || article === void 0 || (_article$boldDescript2 = article.boldDescription) === null || _article$boldDescript2 === void 0 || (_article$boldDescript2 = _article$boldDescript2.ops) === null || _article$boldDescript2 === void 0 || (_article$boldDescript2 = _article$boldDescript2[0]) === null || _article$boldDescript2 === void 0 ? void 0 : _article$boldDescript2.insert) !== null && _article$boldDescript !== void 0 ? _article$boldDescript : null,
203
210
  specifications: Array.isArray(article === null || article === void 0 ? void 0 : article.specifications) ? article === null || article === void 0 ? void 0 : article.specifications.join(' \n ') : (_article$specificatio = article === null || article === void 0 ? void 0 : article.specifications) !== null && _article$specificatio !== void 0 ? _article$specificatio : null,
204
211
  image: article !== null && article !== void 0 && (_article$images = article.images) !== null && _article$images !== void 0 && _article$images[0] ? (0, _image.getImageFromHyper)({
@@ -210,11 +217,11 @@ const formatModelArticle = article => {
210
217
  const formatGenericArticle = article => {
211
218
  var _article$images3, _article$images4, _article$articleNumbe2;
212
219
  const specificationPairs = [['C2 module', article === null || article === void 0 ? void 0 : article.c2Module], ['Check control', article === null || article === void 0 ? void 0 : article.checkControl], ['Direct current', article === null || article === void 0 ? void 0 : article.directCurrent], ['Draw weight', article === null || article === void 0 ? void 0 : article.drawWeight], ['D value', article === null || article === void 0 ? void 0 : article.dValue], ['Foglight shutdown', article === null || article === void 0 ? void 0 : article.foglightShutdown], ['PDC shutdown', article === null || article === void 0 ? void 0 : article.pdcShutdown], ['Switched PSU', article === null || article === void 0 ? void 0 : article.switchedPsu], ['LED', article === null || article === void 0 ? void 0 : article.led]];
213
- const specification = specificationPairs.filter(_ref => {
214
- let [_, value] = _ref;
220
+ const specification = specificationPairs.filter(_ref3 => {
221
+ let [_, value] = _ref3;
215
222
  return value;
216
- }).map(_ref2 => {
217
- let [label, value] = _ref2;
223
+ }).map(_ref4 => {
224
+ let [label, value] = _ref4;
218
225
  return "".concat(label, ": ").concat(value);
219
226
  }).join(' \n ');
220
227
  return {
@@ -191,7 +191,22 @@ const InternalSingleOrderPage = () => {
191
191
  });
192
192
  }
193
193
  };
194
- const toggleLicenseplateModal = () => {
194
+ const filterModelOrLicenseplate = filter => {
195
+ if (filter.type === 'licenseplate') {
196
+ dispatch({
197
+ type: _OrderSessionContext.orderSessionActions.SET_LICENSE_PLATE,
198
+ payload: {
199
+ licensePlate: filter.value
200
+ }
201
+ });
202
+ } else {
203
+ dispatch({
204
+ type: _OrderSessionContext.orderSessionActions.SET_MODEL,
205
+ payload: {
206
+ model: filter.value
207
+ }
208
+ });
209
+ }
195
210
  setIsLicenseplateModalOpen(!isLicenseplateModalOpen);
196
211
  };
197
212
  const removeFromCart = (0, _react.useCallback)(articleNumber => {
@@ -230,7 +245,7 @@ const InternalSingleOrderPage = () => {
230
245
  className: (0, _helpers__.withStyle)(wrapperClass)
231
246
  }, /*#__PURE__*/_react.default.createElement(_InternalLicenseplateModal.default, {
232
247
  isOpen: isLicenseplateModalOpen,
233
- onSubmit: toggleLicenseplateModal,
248
+ onSubmit: filterModelOrLicenseplate,
234
249
  handleSelectedFilterChange: handleSelectedFilterChange
235
250
  }), /*#__PURE__*/_react.default.createElement("div", {
236
251
  className: (0, _helpers__.withStyle)('container page-content')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",