@crystaldesign/product-handler 24.15.0-beta.5 → 24.15.0-beta.51

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.
@@ -58,6 +58,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
58
58
  _defineProperty__default["default"](this, "_apiKey", void 0);
59
59
  _defineProperty__default["default"](this, "_catalogService", '');
60
60
  _defineProperty__default["default"](this, "_mediaService", '');
61
+ _defineProperty__default["default"](this, "_basketService", '');
61
62
  _defineProperty__default["default"](this, "_api2", '');
62
63
  _defineProperty__default["default"](this, "_sessionGuid", '');
63
64
  _defineProperty__default["default"](this, "_organization", {});
@@ -78,6 +79,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
78
79
  set: function set(val) {
79
80
  this._catalogService = val;
80
81
  }
82
+ }, {
83
+ key: "basketService",
84
+ get: function get() {
85
+ return this._basketService;
86
+ },
87
+ set: function set(val) {
88
+ this._basketService = val;
89
+ }
81
90
  }, {
82
91
  key: "mediaService",
83
92
  get: function get() {
@@ -202,46 +211,47 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
202
211
  value: (function () {
203
212
  var _loadProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(_ref2) {
204
213
  var _this = this,
214
+ _baseProduct$divaNr,
205
215
  _baseProduct,
206
- _basket$getProductCon,
207
216
  _baseProduct2,
208
217
  _baseProduct3,
209
- _baseProduct$divaNr,
218
+ _basket$getProductCon,
210
219
  _baseProduct4,
220
+ _baseProduct5,
211
221
  _dataByBasket$price$a,
212
222
  _dataByBasket$price,
213
- _baseProduct5,
214
- _dataByBasket$image,
215
223
  _baseProduct6,
216
- _dataByBasket$image2D,
224
+ _dataByBasket$image,
217
225
  _baseProduct7,
218
- _dataByBasket$docking,
226
+ _dataByBasket$image2D,
219
227
  _baseProduct8,
220
- _baseProduct$organiza,
228
+ _dataByBasket$docking,
221
229
  _baseProduct9,
230
+ _baseProduct$organiza,
231
+ _baseProduct10,
222
232
  _this$organization$pa,
223
233
  _this$organization$pa2,
224
234
  _baseProduct$createdB,
225
- _baseProduct10,
226
- _this$user,
227
235
  _baseProduct11,
236
+ _this$user,
228
237
  _baseProduct12,
229
238
  _baseProduct13,
230
239
  _baseProduct14,
231
- _dataByBasket$orderTe,
232
240
  _baseProduct15,
233
- _dataByBasket$technic,
241
+ _dataByBasket$orderTe,
234
242
  _baseProduct16,
243
+ _dataByBasket$technic,
235
244
  _baseProduct17,
245
+ _baseProduct18,
236
246
  _ref3,
237
247
  _baseProduct$configur3,
238
- _baseProduct18;
239
- var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, products, baseProduct, variantProducts, _baseProduct$configur, _baseProduct$configur2, _basket$OrderSets$map, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, configuration, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$, opts, _i, initializedOptMap;
248
+ _baseProduct19;
249
+ var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, getUniqueNewDivaNr, products, baseProduct, variantProducts, _baseProduct$configur, _baseProduct$configur2, _basket$OrderSets$map, myDivaNr, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, configuration, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$, opts, _i, initializedOptMap;
240
250
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
241
251
  while (1) switch (_context2.prev = _context2.next) {
242
252
  case 0:
243
- basket = _ref2.basket, divaNr = _ref2.divaNr, catalogData = _ref2.catalogData, productData = _ref2.productData, classificationFields = _ref2.classificationFields, fieldConfiguration = _ref2.fieldConfiguration, customBaseFields = _ref2.customBaseFields, classificationConfig = _ref2.classificationConfig, _ref2$availableLangua = _ref2.availableLanguages, availableLanguages = _ref2$availableLangua === void 0 ? ['de', 'fr', 'it', 'en'] : _ref2$availableLangua, _ref2$currentLang = _ref2.currentLang, currentLang = _ref2$currentLang === void 0 ? 'de' : _ref2$currentLang;
244
- if (!(!productData && !divaNr)) {
253
+ basket = _ref2.basket, divaNr = _ref2.divaNr, catalogData = _ref2.catalogData, productData = _ref2.productData, classificationFields = _ref2.classificationFields, fieldConfiguration = _ref2.fieldConfiguration, customBaseFields = _ref2.customBaseFields, classificationConfig = _ref2.classificationConfig, _ref2$availableLangua = _ref2.availableLanguages, availableLanguages = _ref2$availableLangua === void 0 ? ['de', 'fr', 'it', 'en'] : _ref2$availableLangua, _ref2$currentLang = _ref2.currentLang, currentLang = _ref2$currentLang === void 0 ? 'de' : _ref2$currentLang, getUniqueNewDivaNr = _ref2.getUniqueNewDivaNr;
254
+ if (!(!productData && !divaNr && !getUniqueNewDivaNr)) {
245
255
  _context2.next = 3;
246
256
  break;
247
257
  }
@@ -308,7 +318,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
308
318
  }
309
319
  throw new Error('If existing products are fetched, there has to be atleast a base product.');
310
320
  case 25:
311
- dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct); //to remember what for position was previously set for the classification
321
+ myDivaNr = (_baseProduct$divaNr = (_baseProduct = baseProduct) === null || _baseProduct === void 0 ? void 0 : _baseProduct.divaNr) !== null && _baseProduct$divaNr !== void 0 ? _baseProduct$divaNr : basket === null || basket === void 0 ? void 0 : basket.DivaNr;
322
+ if (!(!((_baseProduct2 = baseProduct) !== null && _baseProduct2 !== void 0 && _baseProduct2.divaNr) && getUniqueNewDivaNr)) {
323
+ _context2.next = 30;
324
+ break;
325
+ }
326
+ _context2.next = 29;
327
+ return this.apiGetUniqueDivaNr();
328
+ case 29:
329
+ myDivaNr = _context2.sent;
330
+ case 30:
331
+ dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct, getUniqueNewDivaNr ? myDivaNr : undefined); //to remember what for position was previously set for the classification
312
332
  oldClassificationData = {};
313
333
  for (i = 0; i < products.data.length; i++) {
314
334
  variant = products.data[i];
@@ -319,27 +339,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
319
339
  }
320
340
  }
321
341
  }
322
- oldUniqueHash = (_baseProduct = baseProduct) === null || _baseProduct === void 0 ? void 0 : _baseProduct.uniqueHash;
323
- configuration = (_basket$getProductCon = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration()) !== null && _basket$getProductCon !== void 0 ? _basket$getProductCon : (_baseProduct2 = baseProduct) === null || _baseProduct2 === void 0 ? void 0 : _baseProduct2.configuration;
342
+ oldUniqueHash = (_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3.uniqueHash;
343
+ configuration = (_basket$getProductCon = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration()) !== null && _basket$getProductCon !== void 0 ? _basket$getProductCon : (_baseProduct4 = baseProduct) === null || _baseProduct4 === void 0 ? void 0 : _baseProduct4.configuration;
344
+ if (getUniqueNewDivaNr && myDivaNr) {
345
+ configuration = _objectSpread(_objectSpread({}, configuration), {}, {
346
+ DivaNr: myDivaNr
347
+ });
348
+ }
324
349
  baseData = _objectSpread(_objectSpread(_objectSpread({}, dataByBasket), baseProduct), {}, {
325
- _id: ((_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3._id) || DivaUtils.nanoid(),
326
- divaNr: (_baseProduct$divaNr = (_baseProduct4 = baseProduct) === null || _baseProduct4 === void 0 ? void 0 : _baseProduct4.divaNr) !== null && _baseProduct$divaNr !== void 0 ? _baseProduct$divaNr : basket === null || basket === void 0 ? void 0 : basket.DivaNr,
327
- addedPrice: (_dataByBasket$price$a = dataByBasket === null || dataByBasket === void 0 || (_dataByBasket$price = dataByBasket.price) === null || _dataByBasket$price === void 0 ? void 0 : _dataByBasket$price.addedPrice) !== null && _dataByBasket$price$a !== void 0 ? _dataByBasket$price$a : (_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5.addedPrice,
328
- image: (_dataByBasket$image = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image) !== null && _dataByBasket$image !== void 0 ? _dataByBasket$image : (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.image,
329
- image2D: (_dataByBasket$image2D = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image2D) !== null && _dataByBasket$image2D !== void 0 ? _dataByBasket$image2D : (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.image2D,
350
+ _id: ((_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5._id) || DivaUtils.nanoid(),
351
+ divaNr: myDivaNr,
352
+ addedPrice: (_dataByBasket$price$a = dataByBasket === null || dataByBasket === void 0 || (_dataByBasket$price = dataByBasket.price) === null || _dataByBasket$price === void 0 ? void 0 : _dataByBasket$price.addedPrice) !== null && _dataByBasket$price$a !== void 0 ? _dataByBasket$price$a : (_baseProduct6 = baseProduct) === null || _baseProduct6 === void 0 ? void 0 : _baseProduct6.addedPrice,
353
+ image: (_dataByBasket$image = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image) !== null && _dataByBasket$image !== void 0 ? _dataByBasket$image : (_baseProduct7 = baseProduct) === null || _baseProduct7 === void 0 ? void 0 : _baseProduct7.image,
354
+ image2D: (_dataByBasket$image2D = dataByBasket === null || dataByBasket === void 0 ? void 0 : dataByBasket.image2D) !== null && _dataByBasket$image2D !== void 0 ? _dataByBasket$image2D : (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.image2D,
330
355
  configuration: configuration,
331
- dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.dockingPoints,
356
+ dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.dockingPoints,
332
357
  currency: DivaUtils__default["default"].defaultPriceFormat.currency,
333
- organizationId: (_baseProduct$organiza = (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
358
+ organizationId: (_baseProduct$organiza = (_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
334
359
  inheritedOrganizations: [].concat(_toConsumableArray__default["default"]((_this$organization$pa = (_this$organization$pa2 = this.organization.parentOrganizations) === null || _this$organization$pa2 === void 0 ? void 0 : _this$organization$pa2.map(function (o) {
335
360
  return o._id;
336
361
  })) !== null && _this$organization$pa !== void 0 ? _this$organization$pa : []), [this.organization._id]),
337
- createdBy: (_baseProduct$createdB = (_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
338
- createdBy_displayText: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.createdBy_displayText,
339
- archived: (_baseProduct12 = baseProduct) !== null && _baseProduct12 !== void 0 && _baseProduct12.archived ? (_baseProduct13 = baseProduct) === null || _baseProduct13 === void 0 ? void 0 : _baseProduct13.archived : false,
340
- isTopseller: !!((_baseProduct14 = baseProduct) !== null && _baseProduct14 !== void 0 && _baseProduct14.isTopseller),
341
- orderText: (_dataByBasket$orderTe = dataByBasket.orderText) !== null && _dataByBasket$orderTe !== void 0 ? _dataByBasket$orderTe : (_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.orderText,
342
- technicalDescription: (_dataByBasket$technic = dataByBasket.technicalDescription) !== null && _dataByBasket$technic !== void 0 ? _dataByBasket$technic : (_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16.technicalDescription
362
+ createdBy: (_baseProduct$createdB = (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.createdBy) !== null && _baseProduct$createdB !== void 0 ? _baseProduct$createdB : (_this$user = this.user) === null || _this$user === void 0 ? void 0 : _this$user._id,
363
+ createdBy_displayText: (_baseProduct12 = baseProduct) === null || _baseProduct12 === void 0 ? void 0 : _baseProduct12.createdBy_displayText,
364
+ archived: (_baseProduct13 = baseProduct) !== null && _baseProduct13 !== void 0 && _baseProduct13.archived ? (_baseProduct14 = baseProduct) === null || _baseProduct14 === void 0 ? void 0 : _baseProduct14.archived : false,
365
+ isTopseller: !!((_baseProduct15 = baseProduct) !== null && _baseProduct15 !== void 0 && _baseProduct15.isTopseller),
366
+ orderText: (_dataByBasket$orderTe = dataByBasket.orderText) !== null && _dataByBasket$orderTe !== void 0 ? _dataByBasket$orderTe : (_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16.orderText,
367
+ technicalDescription: (_dataByBasket$technic = dataByBasket.technicalDescription) !== null && _dataByBasket$technic !== void 0 ? _dataByBasket$technic : (_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.technicalDescription
343
368
  });
344
369
  metaData = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
345
370
  return _objectSpread(_objectSpread({}, prev), curr.MetaData || {});
@@ -348,7 +373,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
348
373
  return _objectSpread(_objectSpread({}, prev), curr.MetaData_locales || {});
349
374
  }, {});
350
375
  _this$parseMetaDataAn = this.parseMetaDataAndClassificationInformation(metaData, metaData_locales, baseProduct, classificationConfig, customBaseFields), classificationData = _this$parseMetaDataAn.classificationData, customData = _this$parseMetaDataAn.customData, optMap = _this$parseMetaDataAn.optMap;
351
- baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.customData), customData);
376
+ baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.customData), customData);
352
377
 
353
378
  //add livingarea,maincategorie,subcategorie of loaded product if not exists
354
379
  classificationConfig = this.checkAndAddClassificationConfigCategories(baseProduct, classificationConfig);
@@ -365,11 +390,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
365
390
  optFields = [];
366
391
  initialSelectedFields = [];
367
392
  if (!dataByBasket.isSet) {
368
- _context2.next = 46;
393
+ _context2.next = 52;
369
394
  break;
370
395
  }
371
396
  throw new Error('Variants are currently not supported for set products');
372
- case 46:
397
+ case 52:
373
398
  //iterate all existing variant products and add them to the variants
374
399
  usedVariantIds = [];
375
400
  variantProducts.forEach(function (product) {
@@ -425,7 +450,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
425
450
  }
426
451
 
427
452
  //get opt data
428
- differingOPTs = Object.entries(((_ref3 = (_baseProduct$configur3 = (_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.configuration) !== null && _baseProduct$configur3 !== void 0 ? _baseProduct$configur3 : basket) === null || _ref3 === void 0 || (_ref3 = _ref3.OrderSets[0].Favorites) === null || _ref3 === void 0 ? void 0 : _ref3.VariantValues) || []).filter(function (_ref4) {
453
+ differingOPTs = Object.entries(((_ref3 = (_baseProduct$configur3 = (_baseProduct19 = baseProduct) === null || _baseProduct19 === void 0 ? void 0 : _baseProduct19.configuration) !== null && _baseProduct$configur3 !== void 0 ? _baseProduct$configur3 : basket) === null || _ref3 === void 0 || (_ref3 = _ref3.OrderSets[0].Favorites) === null || _ref3 === void 0 ? void 0 : _ref3.VariantValues) || []).filter(function (_ref4) {
429
454
  var _ref5 = _slicedToArray__default["default"](_ref4, 2);
430
455
  _ref5[0];
431
456
  var value = _ref5[1];
@@ -500,7 +525,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
500
525
  availableLanguages: availableLanguages,
501
526
  currentLang: currentLang
502
527
  });
503
- case 59:
528
+ case 65:
504
529
  case "end":
505
530
  return _context2.stop();
506
531
  }
@@ -513,7 +538,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
513
538
  }())
514
539
  }, {
515
540
  key: "getProductDataByBasket",
516
- value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct) {
541
+ value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct, customDivaNr) {
517
542
  var dataByBasket = {};
518
543
  var isSet = !!(basket !== null && basket !== void 0 && basket.SetPlannerInfos);
519
544
  dataByBasket.isSet = isSet;
@@ -689,7 +714,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
689
714
  }).filter(function (f) {
690
715
  return f;
691
716
  });
692
- dataByBasket.orderText = basket.getEKText(true);
717
+ dataByBasket.orderText = basket.getEKText(true, customDivaNr);
693
718
  dataByBasket.uniqueHash = isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
694
719
  return os.SetHash;
695
720
  }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject);
@@ -843,10 +868,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
843
868
  this.trimStrings(baseData);
844
869
  //the base product is constructed, based on baseData and classification data
845
870
  baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev, _ref13) {
871
+ var _fieldConfiguration$c;
846
872
  var _ref14 = _slicedToArray__default["default"](_ref13, 2),
847
873
  key = _ref14[0],
848
874
  value = _ref14[1];
849
- prev["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.classMap[key].values);
875
+ prev["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 || (_fieldConfiguration$c = fieldConfiguration.classMap[key]) === null || _fieldConfiguration$c === void 0 ? void 0 : _fieldConfiguration$c.values);
850
876
  return prev;
851
877
  }, {})), {}, {
852
878
  _id: originProductId && !(variantData !== null && variantData !== void 0 && variantData.length) ? originProductId : baseData._id,
@@ -876,11 +902,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
876
902
  var value = _ref18[1];
877
903
  return value;
878
904
  }).forEach(function (_ref19) {
879
- var _baseProduct19;
905
+ var _baseProduct20;
880
906
  var _ref20 = _slicedToArray__default["default"](_ref19, 2),
881
907
  key = _ref20[0],
882
908
  value = _ref20[1];
883
- return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct19 = baseProduct["dc_".concat(key)]) !== null && _baseProduct19 !== void 0 ? _baseProduct19 : {}), {}, {
909
+ return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct20 = baseProduct["dc_".concat(key)]) !== null && _baseProduct20 !== void 0 ? _baseProduct20 : {}), {}, {
884
910
  opt: value.field
885
911
  });
886
912
  });
@@ -1282,6 +1308,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1282
1308
  if (isManual) {
1283
1309
  addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
1284
1310
  }
1311
+ var discountedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.discountedPrice;
1312
+ var noDiscountManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.discountedPrice) === undefined && (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.percentageDiscount) === 0;
1313
+ if (noDiscountManual) {
1314
+ discountedPrice = undefined;
1315
+ }
1285
1316
  var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
1286
1317
  classificationData = _this$parseMetaDataAn2.classificationData,
1287
1318
  customData = _this$parseMetaDataAn2.customData;
@@ -1305,6 +1336,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1305
1336
  //only if cv is not defined fallback to the values in product
1306
1337
  addedPrice: addedPrice,
1307
1338
  calculatedPrice: price.calculatedPrice,
1339
+ discountedPrice: discountedPrice,
1308
1340
  variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
1309
1341
  image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
1310
1342
  image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
@@ -1975,12 +2007,62 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1975
2007
  return apiMarkAsFavorite;
1976
2008
  }()
1977
2009
  }, {
1978
- key: "apiDeleteProducts",
2010
+ key: "apiGetUniqueDivaNr",
1979
2011
  value: function () {
1980
- var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12(products) {
1981
- var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
2012
+ var _apiGetUniqueDivaNr = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12() {
2013
+ var _res5;
2014
+ var fullUrl, res, resData;
1982
2015
  return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context14) {
1983
2016
  while (1) switch (_context14.prev = _context14.next) {
2017
+ case 0:
2018
+ fullUrl = new URL(this.basketService + '/baskets/uniqueDivaNr');
2019
+ _context14.prev = 1;
2020
+ _context14.next = 4;
2021
+ return axios__default["default"].get(fullUrl.toString(), {
2022
+ headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
2023
+ 'Content-Type': 'application/json'
2024
+ })
2025
+ });
2026
+ case 4:
2027
+ res = _context14.sent;
2028
+ _context14.next = 7;
2029
+ return res.data;
2030
+ case 7:
2031
+ resData = _context14.sent;
2032
+ _context14.next = 13;
2033
+ break;
2034
+ case 10:
2035
+ _context14.prev = 10;
2036
+ _context14.t0 = _context14["catch"](1);
2037
+ throw new Error('Error on activate product', {
2038
+ cause: _context14.t0
2039
+ });
2040
+ case 13:
2041
+ if (!(((_res5 = res) === null || _res5 === void 0 ? void 0 : _res5.status) == 200)) {
2042
+ _context14.next = 15;
2043
+ break;
2044
+ }
2045
+ return _context14.abrupt("return", resData.divaNr);
2046
+ case 15:
2047
+ throw new Error(resData.error);
2048
+ case 16:
2049
+ case "end":
2050
+ return _context14.stop();
2051
+ }
2052
+ }, _callee12, this, [[1, 10]]);
2053
+ }));
2054
+ function apiGetUniqueDivaNr() {
2055
+ return _apiGetUniqueDivaNr.apply(this, arguments);
2056
+ }
2057
+ return apiGetUniqueDivaNr;
2058
+ }()
2059
+ }, {
2060
+ key: "apiDeleteProducts",
2061
+ value: function () {
2062
+ var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(products) {
2063
+ var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
2064
+ return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context15) {
2065
+ while (1) switch (_context15.prev = _context15.next) {
1984
2066
  case 0:
1985
2067
  fullUrl = this.catalogService + '/products';
1986
2068
  fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
@@ -1991,7 +2073,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1991
2073
  i = 0;
1992
2074
  case 5:
1993
2075
  if (!(i < productsInChunks.length)) {
1994
- _context14.next = 13;
2076
+ _context15.next = 13;
1995
2077
  break;
1996
2078
  }
1997
2079
  promises = productsInChunks[i].map(function (p) {
@@ -2013,17 +2095,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2013
2095
  title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
2014
2096
  dontRenderForm: true
2015
2097
  });
2016
- _context14.next = 10;
2098
+ _context15.next = 10;
2017
2099
  return Promise.all(promises);
2018
2100
  case 10:
2019
2101
  i++;
2020
- _context14.next = 5;
2102
+ _context15.next = 5;
2021
2103
  break;
2022
2104
  case 13:
2023
2105
  case "end":
2024
- return _context14.stop();
2106
+ return _context15.stop();
2025
2107
  }
2026
- }, _callee12, this);
2108
+ }, _callee13, this);
2027
2109
  }));
2028
2110
  function apiDeleteProducts(_x20) {
2029
2111
  return _apiDeleteProducts.apply(this, arguments);
@@ -2042,13 +2124,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2042
2124
  }, {
2043
2125
  key: "apiLoadProductVariantsGrouped",
2044
2126
  value: function () {
2045
- var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(_ref45) {
2127
+ var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(_ref45) {
2046
2128
  var limit, skip, fields, _ref45$search, search, sort, favorites, abortController, fullUrl, headers, promise;
2047
- return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context15) {
2048
- while (1) switch (_context15.prev = _context15.next) {
2129
+ return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context16) {
2130
+ while (1) switch (_context16.prev = _context16.next) {
2049
2131
  case 0:
2050
2132
  limit = _ref45.limit, skip = _ref45.skip, fields = _ref45.fields, _ref45$search = _ref45.search, search = _ref45$search === void 0 ? [] : _ref45$search, sort = _ref45.sort, favorites = _ref45.favorites, abortController = _ref45.abortController;
2051
- fullUrl = this.catalogService + '/v1/products/groups' + '?organizationId=' + this.organization._id + (this._organization.parentOrganizationIds ? '&parentOrganizationIds=' + this._organization.parentOrganizationIds.join(',') : '') + (limit ? '&limit=' + limit : '') + (skip ? '&skip=' + skip : '') + (fields ? '&fileds=' + DivaUtils__default["default"].fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search ? '&search=' + DivaUtils__default["default"].fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils__default["default"].fixedEncodeURIComponent(sort) : '') + (favorites ? '&favorites=true' : '');
2133
+ fullUrl = this.catalogService + '/v1/products/groups' + '?organizationId=' + this.organization._id + (this._organization.parentOrganizationIds ? '&parentOrganizationIds=' + this._organization.parentOrganizationIds.join(',') : '') + (limit ? '&limit=' + limit : '') + (skip ? '&skip=' + skip : '') + (fields ? '&fileds=' + DivaUtils__default["default"].fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search.length ? '&search=' + DivaUtils__default["default"].fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils__default["default"].fixedEncodeURIComponent(sort) : '') + (favorites ? '&favorites=true' : '');
2052
2134
  headers = {
2053
2135
  'Content-Type': 'application/json'
2054
2136
  };
@@ -2069,15 +2151,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2069
2151
  reject('Error loading products grouped by variants: ' + error.message);
2070
2152
  });
2071
2153
  });
2072
- _context15.next = 7;
2154
+ _context16.next = 7;
2073
2155
  return promise;
2074
2156
  case 7:
2075
- return _context15.abrupt("return", _context15.sent);
2157
+ return _context16.abrupt("return", _context16.sent);
2076
2158
  case 8:
2077
2159
  case "end":
2078
- return _context15.stop();
2160
+ return _context16.stop();
2079
2161
  }
2080
- }, _callee13, this);
2162
+ }, _callee14, this);
2081
2163
  }));
2082
2164
  function apiLoadProductVariantsGrouped(_x21) {
2083
2165
  return _apiLoadProductVariantsGrouped.apply(this, arguments);
@@ -2087,46 +2169,46 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2087
2169
  }, {
2088
2170
  key: "apiSaveProducts",
2089
2171
  value: function () {
2090
- var _apiSaveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2172
+ var _apiSaveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee15(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2091
2173
  var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2, _loop3, j;
2092
- return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context17) {
2093
- while (1) switch (_context17.prev = _context17.next) {
2174
+ return _regeneratorRuntime__default["default"].wrap(function _callee15$(_context18) {
2175
+ while (1) switch (_context18.prev = _context18.next) {
2094
2176
  case 0:
2095
2177
  fullUrl = serverUrl + '/v1/products/groups';
2096
- BATCH_SIZE = 40;
2178
+ BATCH_SIZE = 10;
2097
2179
  productsPackages = [];
2098
2180
  groupIndex = 0;
2099
2181
  i = 0;
2100
2182
  case 5:
2101
2183
  if (!(i < products.length)) {
2102
- _context17.next = 15;
2184
+ _context18.next = 15;
2103
2185
  break;
2104
2186
  }
2105
2187
  if (!products[i].baseProduct) {
2106
- _context17.next = 9;
2188
+ _context18.next = 9;
2107
2189
  break;
2108
2190
  }
2109
2191
  baseProduct = products[i];
2110
- return _context17.abrupt("continue", 12);
2192
+ return _context18.abrupt("continue", 12);
2111
2193
  case 9:
2112
2194
  if (BATCH_SIZE < ((_productsPackages$gro = (_productsPackages$gro2 = productsPackages[groupIndex]) === null || _productsPackages$gro2 === void 0 ? void 0 : _productsPackages$gro2.length) !== null && _productsPackages$gro !== void 0 ? _productsPackages$gro : 0)) groupIndex++;
2113
2195
  if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
2114
2196
  productsPackages[groupIndex].push(products[i]);
2115
2197
  case 12:
2116
2198
  i++;
2117
- _context17.next = 5;
2199
+ _context18.next = 5;
2118
2200
  break;
2119
2201
  case 15:
2120
2202
  responseProducts = [];
2121
2203
  _i2 = 0;
2122
2204
  case 17:
2123
2205
  if (!(_i2 < productsPackages.length)) {
2124
- _context17.next = 40;
2206
+ _context18.next = 40;
2125
2207
  break;
2126
2208
  }
2127
- if (baseProduct) productsPackages[_i2].unshift(baseProduct);
2128
- _context17.prev = 19;
2129
- _context17.next = 22;
2209
+ if (baseProduct && _i2 == 0) productsPackages[_i2].unshift(baseProduct);
2210
+ _context18.prev = 19;
2211
+ _context18.next = 22;
2130
2212
  return fetch(fullUrl, {
2131
2213
  method: 'PUT',
2132
2214
  headers: {
@@ -2146,23 +2228,23 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2146
2228
  return res.json();
2147
2229
  });
2148
2230
  case 22:
2149
- response = _context17.sent;
2231
+ response = _context18.sent;
2150
2232
  if (!response.Error) {
2151
- _context17.next = 25;
2233
+ _context18.next = 25;
2152
2234
  break;
2153
2235
  }
2154
2236
  throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
2155
2237
  case 25:
2156
- _context17.next = 30;
2238
+ _context18.next = 30;
2157
2239
  break;
2158
2240
  case 27:
2159
- _context17.prev = 27;
2160
- _context17.t0 = _context17["catch"](19);
2241
+ _context18.prev = 27;
2242
+ _context18.t0 = _context18["catch"](19);
2161
2243
  throw Error(status);
2162
2244
  case 30:
2163
2245
  _loop3 = /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _loop3(j) {
2164
- return _regeneratorRuntime__default["default"].wrap(function _loop3$(_context16) {
2165
- while (1) switch (_context16.prev = _context16.next) {
2246
+ return _regeneratorRuntime__default["default"].wrap(function _loop3$(_context17) {
2247
+ while (1) switch (_context17.prev = _context17.next) {
2166
2248
  case 0:
2167
2249
  if (response.products[j].baseProduct) baseProduct = response.products[j];
2168
2250
  if (!responseProducts.find(function (p) {
@@ -2172,32 +2254,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2172
2254
  }
2173
2255
  case 2:
2174
2256
  case "end":
2175
- return _context16.stop();
2257
+ return _context17.stop();
2176
2258
  }
2177
2259
  }, _loop3);
2178
2260
  });
2179
2261
  j = 0;
2180
2262
  case 32:
2181
2263
  if (!(j < response.products.length)) {
2182
- _context17.next = 37;
2264
+ _context18.next = 37;
2183
2265
  break;
2184
2266
  }
2185
- return _context17.delegateYield(_loop3(j), "t1", 34);
2267
+ return _context18.delegateYield(_loop3(j), "t1", 34);
2186
2268
  case 34:
2187
2269
  j++;
2188
- _context17.next = 32;
2270
+ _context18.next = 32;
2189
2271
  break;
2190
2272
  case 37:
2191
2273
  _i2++;
2192
- _context17.next = 17;
2274
+ _context18.next = 17;
2193
2275
  break;
2194
2276
  case 40:
2195
- return _context17.abrupt("return", responseProducts);
2277
+ return _context18.abrupt("return", responseProducts);
2196
2278
  case 41:
2197
2279
  case "end":
2198
- return _context17.stop();
2280
+ return _context18.stop();
2199
2281
  }
2200
- }, _callee14, null, [[19, 27]]);
2282
+ }, _callee15, null, [[19, 27]]);
2201
2283
  }));
2202
2284
  function apiSaveProducts(_x22, _x23, _x24, _x25, _x26) {
2203
2285
  return _apiSaveProducts.apply(this, arguments);
@@ -2424,10 +2506,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2424
2506
  }, {
2425
2507
  key: "loadSelectOptions",
2426
2508
  value: function () {
2427
- var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
2509
+ var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee16(sessionGuid, dataSource, additionalFilter) {
2428
2510
  var values, apiUrl, i, apiResult, _i3, value, text;
2429
- return _regeneratorRuntime__default["default"].wrap(function _callee15$(_context18) {
2430
- while (1) switch (_context18.prev = _context18.next) {
2511
+ return _regeneratorRuntime__default["default"].wrap(function _callee16$(_context19) {
2512
+ while (1) switch (_context19.prev = _context19.next) {
2431
2513
  case 0:
2432
2514
  values = [];
2433
2515
  apiUrl = dataSource.url;
@@ -2436,7 +2518,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2436
2518
  apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
2437
2519
  }
2438
2520
  }
2439
- _context18.next = 5;
2521
+ _context19.next = 5;
2440
2522
  return fetch(apiUrl, {
2441
2523
  headers: {
2442
2524
  sessionGuid: sessionGuid
@@ -2448,7 +2530,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2448
2530
  return res.json();
2449
2531
  });
2450
2532
  case 5:
2451
- apiResult = _context18.sent;
2533
+ apiResult = _context19.sent;
2452
2534
  if (dataSource.useKey) {
2453
2535
  apiResult = apiResult[dataSource.useKey];
2454
2536
  }
@@ -2460,12 +2542,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2460
2542
  text: text
2461
2543
  });
2462
2544
  }
2463
- return _context18.abrupt("return", values);
2545
+ return _context19.abrupt("return", values);
2464
2546
  case 9:
2465
2547
  case "end":
2466
- return _context18.stop();
2548
+ return _context19.stop();
2467
2549
  }
2468
- }, _callee15);
2550
+ }, _callee16);
2469
2551
  }));
2470
2552
  function loadSelectOptions(_x27, _x28, _x29) {
2471
2553
  return _loadSelectOptions.apply(this, arguments);
@@ -2501,7 +2583,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2501
2583
  OPV: v.OPV,
2502
2584
  OPTName: opt.Name,
2503
2585
  OPVName: opv.Name,
2504
- OPVImage: catalog.mediaUrl + opv.Image
2586
+ OPVImage: opv.Image ? catalog.mediaUrl + opv.Image : undefined
2505
2587
  });
2506
2588
  }
2507
2589
  }