thm-p3-configurator 0.0.367 → 0.0.368
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/index.js +58 -5
- package/dist/src/shared/__components__/internal/InternalCustomerDetailsForm.js +52 -10
- package/dist/src/shared/__containers__/ExtraProductsOverview.js +2 -2
- package/dist/src/shared/__containers__/ProductsOverview.js +2 -2
- package/dist/src/shared/__helpers__/singleOrderArticles.js +13 -13
- package/package.json +1 -1
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.weak-map.js");
|
|
4
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
5
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
6
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
4
7
|
require("core-js/modules/esnext.iterator.map.js");
|
|
5
8
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
6
9
|
require("core-js/modules/es.weak-map.js");
|
|
10
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
11
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
12
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
7
13
|
Object.defineProperty(exports, "__esModule", {
|
|
8
14
|
value: true
|
|
9
15
|
});
|
|
@@ -14,6 +20,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
14
20
|
var _queries = require("../../__api__/queries");
|
|
15
21
|
var _constants__ = require("../../__constants__");
|
|
16
22
|
var _helpers__ = require("../../__helpers__");
|
|
23
|
+
var _singleOrderArticles = require("../../__helpers__/singleOrderArticles");
|
|
17
24
|
var _ProductCardCheckbox = _interopRequireDefault(require("./ProductCardCheckbox"));
|
|
18
25
|
var _ProductCardDescription = _interopRequireDefault(require("./ProductCardDescription"));
|
|
19
26
|
var _ProductCardDiscountAlert = _interopRequireDefault(require("./ProductCardDiscountAlert"));
|
|
@@ -52,8 +59,51 @@ function _interopRequireWildcard(e, r) {
|
|
|
52
59
|
}
|
|
53
60
|
return n.default = e, t && t.set(e, n), n;
|
|
54
61
|
}
|
|
62
|
+
function ownKeys(e, r) {
|
|
63
|
+
var t = Object.keys(e);
|
|
64
|
+
if (Object.getOwnPropertySymbols) {
|
|
65
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
66
|
+
r && (o = o.filter(function (r) {
|
|
67
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
68
|
+
})), t.push.apply(t, o);
|
|
69
|
+
}
|
|
70
|
+
return t;
|
|
71
|
+
}
|
|
72
|
+
function _objectSpread(e) {
|
|
73
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
74
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
75
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
76
|
+
_defineProperty(e, r, t[r]);
|
|
77
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
78
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return e;
|
|
82
|
+
}
|
|
83
|
+
function _defineProperty(e, r, t) {
|
|
84
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
85
|
+
value: t,
|
|
86
|
+
enumerable: !0,
|
|
87
|
+
configurable: !0,
|
|
88
|
+
writable: !0
|
|
89
|
+
}) : e[r] = t, e;
|
|
90
|
+
}
|
|
91
|
+
function _toPropertyKey(t) {
|
|
92
|
+
var i = _toPrimitive(t, "string");
|
|
93
|
+
return "symbol" == typeof i ? i : i + "";
|
|
94
|
+
}
|
|
95
|
+
function _toPrimitive(t, r) {
|
|
96
|
+
if ("object" != typeof t || !t) return t;
|
|
97
|
+
var e = t[Symbol.toPrimitive];
|
|
98
|
+
if (void 0 !== e) {
|
|
99
|
+
var i = e.call(t, r || "default");
|
|
100
|
+
if ("object" != typeof i) return i;
|
|
101
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
102
|
+
}
|
|
103
|
+
return ("string" === r ? String : Number)(t);
|
|
104
|
+
}
|
|
55
105
|
const ProductCard = _ref => {
|
|
56
|
-
var
|
|
106
|
+
var _normalizedStock$quan, _normalizedStock$quan2;
|
|
57
107
|
let {
|
|
58
108
|
hasCheckbox = true,
|
|
59
109
|
isRecommended = false,
|
|
@@ -82,6 +132,9 @@ const ProductCard = _ref => {
|
|
|
82
132
|
const {
|
|
83
133
|
productFieldLabels
|
|
84
134
|
} = (0, _queries.useProductFieldLabels)();
|
|
135
|
+
const normalizedStock = stock && stock.status ? _objectSpread(_objectSpread({}, stock), {}, {
|
|
136
|
+
status: (0, _singleOrderArticles.mapApiStockStatusToStockStatus)(stock.status)
|
|
137
|
+
}) : stock;
|
|
85
138
|
const handleSelected = isSelected => {
|
|
86
139
|
if (!canUnselect && !isSelected) {
|
|
87
140
|
// Do not update local state, only call onSelect
|
|
@@ -159,13 +212,13 @@ const ProductCard = _ref => {
|
|
|
159
212
|
className: (0, _helpers__.withStyle)('card-footer pt-2 col-12 col-md-8 col-xxl-6 pb-0 justify-content-end')
|
|
160
213
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
161
214
|
className: (0, _helpers__.withStyle)('d-flex flex-column align-items-end')
|
|
162
|
-
}, showPrice &&
|
|
215
|
+
}, showPrice && normalizedStock && /*#__PURE__*/_react.default.createElement("div", null, normalizedStock.status === _constants__.StockStatus.OutOfStock ? /*#__PURE__*/_react.default.createElement("div", {
|
|
163
216
|
className: (0, _helpers__.withStyle)('text-danger mb-1')
|
|
164
|
-
}, "Niet op voorraad") :
|
|
217
|
+
}, "Niet op voorraad") : normalizedStock.status === _constants__.StockStatus.InsufficientStock ? /*#__PURE__*/_react.default.createElement("div", {
|
|
165
218
|
className: (0, _helpers__.withStyle)('text-warning mb-1')
|
|
166
|
-
}, isTmg ? "".concat((
|
|
219
|
+
}, isTmg ? "".concat((_normalizedStock$quan = normalizedStock.quantity) !== null && _normalizedStock$quan !== void 0 ? _normalizedStock$quan : 0, " op voorraad") : 'Weinig op voorraad') : /*#__PURE__*/_react.default.createElement("div", {
|
|
167
220
|
className: (0, _helpers__.withStyle)('text-success mb-1')
|
|
168
|
-
}, isTmg ? "".concat((
|
|
221
|
+
}, isTmg ? "".concat((_normalizedStock$quan2 = normalizedStock.quantity) !== null && _normalizedStock$quan2 !== void 0 ? _normalizedStock$quan2 : 0, " op voorraad") : 'Op voorraad')), hasCheckbox && /*#__PURE__*/_react.default.createElement(_ProductCardCheckbox.default, {
|
|
169
222
|
id: productId,
|
|
170
223
|
isDisabled: isDisabled,
|
|
171
224
|
defaultChecked: isSelected,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.array.reduce.js");
|
|
4
4
|
require("core-js/modules/es.promise.js");
|
|
5
|
+
require("core-js/modules/es.string.trim.js");
|
|
5
6
|
require("core-js/modules/es.weak-map.js");
|
|
6
7
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
7
8
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
@@ -18,6 +19,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
18
19
|
exports.default = void 0;
|
|
19
20
|
require("core-js/modules/es.array.reduce.js");
|
|
20
21
|
require("core-js/modules/es.promise.js");
|
|
22
|
+
require("core-js/modules/es.string.trim.js");
|
|
21
23
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
22
24
|
require("core-js/modules/esnext.iterator.find.js");
|
|
23
25
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
@@ -159,7 +161,7 @@ const customerDetailsFormSchema = (0, _yup.object)({
|
|
|
159
161
|
})
|
|
160
162
|
});
|
|
161
163
|
const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
162
|
-
var _branchTypes$byId$aut, _authSession$branch;
|
|
164
|
+
var _customer$vatNumber, _customer$kvkNumber, _branchTypes$byId$aut, _authSession$branch;
|
|
163
165
|
let {
|
|
164
166
|
errors = {},
|
|
165
167
|
onValidationError,
|
|
@@ -249,6 +251,21 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
249
251
|
|
|
250
252
|
// Get customer data for the active ownership type
|
|
251
253
|
const customer = customerDataPerType[activeOwnershipType] || (0, _helpers__.getEmptySingleOrderCustomer)();
|
|
254
|
+
const selectedCountry = (0, _react.useMemo)(() => {
|
|
255
|
+
if (!(countryOptions !== null && countryOptions !== void 0 && countryOptions.length)) return null;
|
|
256
|
+
if (customer !== null && customer !== void 0 && customer.countryId) {
|
|
257
|
+
return countryOptions.find(option => option.value === customer.countryId) || null;
|
|
258
|
+
}
|
|
259
|
+
const defaultCountry = countryOptions.find(option => option.label === 'NEDERLAND');
|
|
260
|
+
return defaultCountry || null;
|
|
261
|
+
}, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions]);
|
|
262
|
+
const isBusinessOwnership = activeOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Zakelijk;
|
|
263
|
+
const isNetherlandsSelected = (0, _react.useMemo)(() => {
|
|
264
|
+
if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
|
|
265
|
+
return selectedCountry.label.toUpperCase() === 'NEDERLAND';
|
|
266
|
+
}, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
|
|
267
|
+
const shouldRequireKvkNumber = isBusinessOwnership && (isNetherlandsSelected || !(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim()));
|
|
268
|
+
const shouldRequireVatNumber = isBusinessOwnership && !isNetherlandsSelected && !(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim());
|
|
252
269
|
|
|
253
270
|
// Helper to update customer data for the active ownership type
|
|
254
271
|
const updateCustomerField = (0, _react.useCallback)((field, value) => {
|
|
@@ -491,6 +508,24 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
491
508
|
}, [addressLookupTimeoutId]);
|
|
492
509
|
const validateForm = async () => {
|
|
493
510
|
try {
|
|
511
|
+
var _customer$kvkNumber2, _customer$vatNumber2;
|
|
512
|
+
const hasKvkNumber = !!(customer !== null && customer !== void 0 && (_customer$kvkNumber2 = customer.kvkNumber) !== null && _customer$kvkNumber2 !== void 0 && _customer$kvkNumber2.trim());
|
|
513
|
+
const hasVatNumber = !!(customer !== null && customer !== void 0 && (_customer$vatNumber2 = customer.vatNumber) !== null && _customer$vatNumber2 !== void 0 && _customer$vatNumber2.trim());
|
|
514
|
+
if (isBusinessOwnership) {
|
|
515
|
+
if (isNetherlandsSelected && !hasKvkNumber) {
|
|
516
|
+
onValidationError === null || onValidationError === void 0 || onValidationError({
|
|
517
|
+
kvkNumber: 'KVK-nummer is verplicht voor zakelijke dossiers in Nederland'
|
|
518
|
+
});
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
if (!isNetherlandsSelected && !hasKvkNumber && !hasVatNumber) {
|
|
522
|
+
onValidationError === null || onValidationError === void 0 || onValidationError({
|
|
523
|
+
kvkNumber: 'Vul een KVK- of BTW-nummer in',
|
|
524
|
+
vatNumber: 'Vul een KVK- of BTW-nummer in'
|
|
525
|
+
});
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
494
529
|
let validationSchema = webshop || !isTmg ? customerDetailsFormSchema.omit(['channelType', 'channelId']) : customerDetailsFormSchema;
|
|
495
530
|
const requiredFields = (0, _helpers__.getSingleOrderRequiredFields)({
|
|
496
531
|
webshop,
|
|
@@ -779,19 +814,21 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
779
814
|
}
|
|
780
815
|
}, branch.name)))), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
781
816
|
placeholder: "",
|
|
782
|
-
|
|
817
|
+
value: customer.kvkNumber,
|
|
783
818
|
name: "kvkNumber",
|
|
784
819
|
onChange: value => updateCustomerField('kvkNumber', value),
|
|
785
|
-
|
|
820
|
+
key: "kvkNumber-".concat(refreshKey),
|
|
821
|
+
isRequired: shouldRequireKvkNumber,
|
|
786
822
|
form: form,
|
|
787
823
|
label: "KVK-nummer:",
|
|
788
824
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['kvkNumber']
|
|
789
825
|
}), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
790
826
|
placeholder: "",
|
|
791
|
-
|
|
827
|
+
value: customer.vatNumber,
|
|
792
828
|
name: "vatNumber",
|
|
793
829
|
onChange: value => updateCustomerField('vatNumber', value),
|
|
794
|
-
|
|
830
|
+
key: "vatNumber-".concat(refreshKey),
|
|
831
|
+
isRequired: shouldRequireVatNumber,
|
|
795
832
|
form: form,
|
|
796
833
|
label: "BTW-nummer:",
|
|
797
834
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['vatNumber']
|
|
@@ -829,7 +866,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
829
866
|
label: "Contact e-mailadres:"
|
|
830
867
|
})) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("br", null)), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
831
868
|
placeholder: "",
|
|
832
|
-
|
|
869
|
+
value: customer.zipCode,
|
|
833
870
|
name: "zipCode",
|
|
834
871
|
onChange: value => {
|
|
835
872
|
updateCustomerField('zipCode', value);
|
|
@@ -839,12 +876,13 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
839
876
|
}
|
|
840
877
|
},
|
|
841
878
|
isRequired: webshop || anderAfleveradres,
|
|
879
|
+
key: "zipCode-".concat(refreshKey),
|
|
842
880
|
form: form,
|
|
843
881
|
label: "Postcode:",
|
|
844
882
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['zipCode']
|
|
845
883
|
}), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
846
884
|
placeholder: "",
|
|
847
|
-
|
|
885
|
+
value: customer.houseNumber,
|
|
848
886
|
name: "houseNumber",
|
|
849
887
|
onChange: value => {
|
|
850
888
|
updateCustomerField('houseNumber', value);
|
|
@@ -854,33 +892,37 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
854
892
|
}
|
|
855
893
|
},
|
|
856
894
|
isRequired: webshop || anderAfleveradres,
|
|
895
|
+
key: "houseNumber-".concat(refreshKey),
|
|
857
896
|
form: form,
|
|
858
897
|
label: "Huisnummer:",
|
|
859
898
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['houseNumber']
|
|
860
899
|
}), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
861
900
|
placeholder: "",
|
|
862
|
-
|
|
901
|
+
value: customer.houseNumberAddition,
|
|
863
902
|
name: "houseNumberAddition",
|
|
864
903
|
onChange: value => updateCustomerField('houseNumberAddition', value),
|
|
865
904
|
isRequired: false,
|
|
905
|
+
key: "houseNumberAddition-".concat(refreshKey),
|
|
866
906
|
form: form,
|
|
867
907
|
label: "Huisnummer toevoeging:",
|
|
868
908
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['houseNumberAddition']
|
|
869
909
|
}), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
870
910
|
placeholder: addressLookupLoading ? 'Adres wordt opgezocht...' : '',
|
|
871
|
-
|
|
911
|
+
value: customer.streetName,
|
|
872
912
|
name: "streetName",
|
|
873
913
|
onChange: value => updateCustomerField('streetName', value),
|
|
874
914
|
isRequired: webshop || anderAfleveradres,
|
|
915
|
+
key: "streetName-".concat(refreshKey),
|
|
875
916
|
form: form,
|
|
876
917
|
label: "Straat:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
|
|
877
918
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['streetName']
|
|
878
919
|
}), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
879
920
|
placeholder: addressLookupLoading ? 'Stad wordt opgezocht...' : '',
|
|
880
|
-
|
|
921
|
+
value: customer.city,
|
|
881
922
|
name: "city",
|
|
882
923
|
onChange: value => updateCustomerField('city', value),
|
|
883
924
|
isRequired: webshop || anderAfleveradres,
|
|
925
|
+
key: "city-".concat(refreshKey),
|
|
884
926
|
form: form,
|
|
885
927
|
label: "Stad:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
|
|
886
928
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
|
|
@@ -192,7 +192,7 @@ const ExtraProductsOverview = () => {
|
|
|
192
192
|
className: (0, _helpers__.withStyle)(index === 0 ? 'mt-0' : 'mt-5'),
|
|
193
193
|
key: "category-".concat(item.categoryName)
|
|
194
194
|
}, /*#__PURE__*/_react.default.createElement("h2", null, item.categoryName), item.products.map((product, index) => {
|
|
195
|
-
var _product$price, _product$locationPric, _product$images, _product$images2, _product$boldDescript;
|
|
195
|
+
var _product$price, _product$consumerPric, _product$consumerPric2, _product$locationPric, _product$images, _product$images2, _product$boldDescript;
|
|
196
196
|
const isSelectedExtra = selectedExtras.hasOwnProperty(product.articleNumber);
|
|
197
197
|
|
|
198
198
|
// GetOrder is the single source of truth for prices
|
|
@@ -202,7 +202,7 @@ const ExtraProductsOverview = () => {
|
|
|
202
202
|
const resolvedProductDiscountedPrice = typeof (product === null || product === void 0 ? void 0 : product.fromPrice) === 'number' ? product.fromPrice : 0;
|
|
203
203
|
return /*#__PURE__*/_react.default.createElement(_ProductCard.default, {
|
|
204
204
|
isTmg: isTmg,
|
|
205
|
-
stock: product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.stock,
|
|
205
|
+
stock: (_product$consumerPric = product === null || product === void 0 || (_product$consumerPric2 = product.consumerPrices) === null || _product$consumerPric2 === void 0 ? void 0 : _product$consumerPric2.stock) !== null && _product$consumerPric !== void 0 ? _product$consumerPric : product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.stock,
|
|
206
206
|
key: product.articleNumber,
|
|
207
207
|
hasCheckbox: true,
|
|
208
208
|
isRecommended: false,
|
|
@@ -345,7 +345,7 @@ const ProductsOverview = () => {
|
|
|
345
345
|
product: a,
|
|
346
346
|
category: productCategory
|
|
347
347
|
}) ? -1 : 0).map(product => {
|
|
348
|
-
var _product$images, _product$images2, _product$locationPric;
|
|
348
|
+
var _product$images, _product$images2, _product$consumerPric, _product$consumerPric2, _product$locationPric;
|
|
349
349
|
const isRecommended = (0, _product.checkIfTowbarIsRecommended)({
|
|
350
350
|
product,
|
|
351
351
|
category: productCategory
|
|
@@ -389,7 +389,7 @@ const ProductsOverview = () => {
|
|
|
389
389
|
}
|
|
390
390
|
return /*#__PURE__*/_react.default.createElement(_ProductCard.default, {
|
|
391
391
|
isTmg: isTmg,
|
|
392
|
-
stock: product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.stock,
|
|
392
|
+
stock: (_product$consumerPric = product === null || product === void 0 || (_product$consumerPric2 = product.consumerPrices) === null || _product$consumerPric2 === void 0 ? void 0 : _product$consumerPric2.stock) !== null && _product$consumerPric !== void 0 ? _product$consumerPric : product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.stock,
|
|
393
393
|
key: product.articleNumber,
|
|
394
394
|
hasCheckbox: (productsPerCategory === null || productsPerCategory === void 0 ? void 0 : productsPerCategory.length) > 1,
|
|
395
395
|
isRecommended: isRecommended,
|
|
@@ -286,11 +286,11 @@ const enrichArticlesWithBrandsAndPrices = exports.enrichArticlesWithBrandsAndPri
|
|
|
286
286
|
throw new Error('Failed to fetch the brands of the articles');
|
|
287
287
|
}
|
|
288
288
|
const articlesWithBrands = articles.map(article => {
|
|
289
|
-
var _ref3, _ref4, _preferredPricePart$
|
|
289
|
+
var _preferredPricePart$p, _ref3, _ref4, _preferredPricePart$p2, _ref5, _brandData$brandNumbe;
|
|
290
290
|
const brandData = findBrandDataForArticle(article, brandResponse.data);
|
|
291
291
|
const preferredPricePart = findPreferredPricePart(article);
|
|
292
|
-
const
|
|
293
|
-
const
|
|
292
|
+
const pricingPartNumber = (_preferredPricePart$p = preferredPricePart === null || preferredPricePart === void 0 ? void 0 : preferredPricePart.partNumber) !== null && _preferredPricePart$p !== void 0 ? _preferredPricePart$p : article.articleNumber;
|
|
293
|
+
const resolvedBrandNumber = preferredPricePart ? (_ref3 = (_ref4 = (_preferredPricePart$p2 = preferredPricePart === null || preferredPricePart === void 0 ? void 0 : preferredPricePart.partBrandId) !== null && _preferredPricePart$p2 !== void 0 ? _preferredPricePart$p2 : brandData === null || brandData === void 0 ? void 0 : brandData.preferredPartBrandNumber) !== null && _ref4 !== void 0 ? _ref4 : brandData === null || brandData === void 0 ? void 0 : brandData.brandNumber) !== null && _ref3 !== void 0 ? _ref3 : _index2.DEFAULT_ARTICLE_BRAND : (_ref5 = (_brandData$brandNumbe = brandData === null || brandData === void 0 ? void 0 : brandData.brandNumber) !== null && _brandData$brandNumbe !== void 0 ? _brandData$brandNumbe : brandData === null || brandData === void 0 ? void 0 : brandData.preferredPartBrandNumber) !== null && _ref5 !== void 0 ? _ref5 : _index2.DEFAULT_ARTICLE_BRAND;
|
|
294
294
|
return _objectSpread(_objectSpread({}, article), {}, {
|
|
295
295
|
brand: resolvedBrandNumber,
|
|
296
296
|
pricingPartNumber
|
|
@@ -318,11 +318,11 @@ const enrichArticlesWithBrandsAndPrices = exports.enrichArticlesWithBrandsAndPri
|
|
|
318
318
|
consumer: Object.fromEntries(consumerPrices.map(price => [price.partNumber, price])),
|
|
319
319
|
location: Object.fromEntries(locationPrices.map(price => [price.partNumber, price]))
|
|
320
320
|
};
|
|
321
|
-
let currentArticles = articlesWithBrands.map(
|
|
321
|
+
let currentArticles = articlesWithBrands.map(_ref6 => {
|
|
322
322
|
let {
|
|
323
323
|
pricingPartNumber
|
|
324
|
-
} =
|
|
325
|
-
article = _objectWithoutProperties(
|
|
324
|
+
} = _ref6,
|
|
325
|
+
article = _objectWithoutProperties(_ref6, _excluded);
|
|
326
326
|
return _objectSpread(_objectSpread({}, article), {}, {
|
|
327
327
|
consumerPrices: pricesMap.consumer[pricingPartNumber],
|
|
328
328
|
locationPrices: pricesMap.location[pricingPartNumber]
|
|
@@ -331,10 +331,10 @@ const enrichArticlesWithBrandsAndPrices = exports.enrichArticlesWithBrandsAndPri
|
|
|
331
331
|
return currentArticles;
|
|
332
332
|
};
|
|
333
333
|
const formatModelArticle = article => {
|
|
334
|
-
var
|
|
334
|
+
var _ref7, _article$name, _ref8, _article$description$, _article$description, _article$boldDescript, _article$boldDescript2, _article$specificatio, _article$images, _article$images2, _article$articleNumbe;
|
|
335
335
|
return _objectSpread(_objectSpread({}, article), {}, {
|
|
336
|
-
name: (
|
|
337
|
-
description: (
|
|
336
|
+
name: (_ref7 = (_article$name = article.name) !== null && _article$name !== void 0 ? _article$name : article === null || article === void 0 ? void 0 : article.title) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
337
|
+
description: (_ref8 = (_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 && _ref8 !== void 0 ? _ref8 : null,
|
|
338
338
|
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,
|
|
339
339
|
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,
|
|
340
340
|
image: article !== null && article !== void 0 && (_article$images = article.images) !== null && _article$images !== void 0 && _article$images[0] ? (0, _image.getImageFromHyper)({
|
|
@@ -349,11 +349,11 @@ const formatModelArticle = article => {
|
|
|
349
349
|
const formatGenericArticle = article => {
|
|
350
350
|
var _article$articleNumbe2, _article$type, _article$group, _article$subgroup;
|
|
351
351
|
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]];
|
|
352
|
-
const specification = specificationPairs.filter(
|
|
353
|
-
let [_, value] =
|
|
352
|
+
const specification = specificationPairs.filter(_ref9 => {
|
|
353
|
+
let [_, value] = _ref9;
|
|
354
354
|
return value;
|
|
355
|
-
}).map(
|
|
356
|
-
let [label, value] =
|
|
355
|
+
}).map(_ref10 => {
|
|
356
|
+
let [label, value] = _ref10;
|
|
357
357
|
return "".concat(label, ": ").concat(value);
|
|
358
358
|
}).join(' \n ');
|
|
359
359
|
return _objectSpread(_objectSpread({}, article), {}, {
|