@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.
@@ -40,6 +40,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
40
40
  _defineProperty(this, "_apiKey", void 0);
41
41
  _defineProperty(this, "_catalogService", '');
42
42
  _defineProperty(this, "_mediaService", '');
43
+ _defineProperty(this, "_basketService", '');
43
44
  _defineProperty(this, "_api2", '');
44
45
  _defineProperty(this, "_sessionGuid", '');
45
46
  _defineProperty(this, "_organization", {});
@@ -60,6 +61,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
60
61
  set: function set(val) {
61
62
  this._catalogService = val;
62
63
  }
64
+ }, {
65
+ key: "basketService",
66
+ get: function get() {
67
+ return this._basketService;
68
+ },
69
+ set: function set(val) {
70
+ this._basketService = val;
71
+ }
63
72
  }, {
64
73
  key: "mediaService",
65
74
  get: function get() {
@@ -184,46 +193,47 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
184
193
  value: (function () {
185
194
  var _loadProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
186
195
  var _this = this,
196
+ _baseProduct$divaNr,
187
197
  _baseProduct,
188
- _basket$getProductCon,
189
198
  _baseProduct2,
190
199
  _baseProduct3,
191
- _baseProduct$divaNr,
200
+ _basket$getProductCon,
192
201
  _baseProduct4,
202
+ _baseProduct5,
193
203
  _dataByBasket$price$a,
194
204
  _dataByBasket$price,
195
- _baseProduct5,
196
- _dataByBasket$image,
197
205
  _baseProduct6,
198
- _dataByBasket$image2D,
206
+ _dataByBasket$image,
199
207
  _baseProduct7,
200
- _dataByBasket$docking,
208
+ _dataByBasket$image2D,
201
209
  _baseProduct8,
202
- _baseProduct$organiza,
210
+ _dataByBasket$docking,
203
211
  _baseProduct9,
212
+ _baseProduct$organiza,
213
+ _baseProduct10,
204
214
  _this$organization$pa,
205
215
  _this$organization$pa2,
206
216
  _baseProduct$createdB,
207
- _baseProduct10,
208
- _this$user,
209
217
  _baseProduct11,
218
+ _this$user,
210
219
  _baseProduct12,
211
220
  _baseProduct13,
212
221
  _baseProduct14,
213
- _dataByBasket$orderTe,
214
222
  _baseProduct15,
215
- _dataByBasket$technic,
223
+ _dataByBasket$orderTe,
216
224
  _baseProduct16,
225
+ _dataByBasket$technic,
217
226
  _baseProduct17,
227
+ _baseProduct18,
218
228
  _ref3,
219
229
  _baseProduct$configur3,
220
- _baseProduct18;
221
- 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;
230
+ _baseProduct19;
231
+ 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;
222
232
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
223
233
  while (1) switch (_context2.prev = _context2.next) {
224
234
  case 0:
225
- 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;
226
- if (!(!productData && !divaNr)) {
235
+ 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;
236
+ if (!(!productData && !divaNr && !getUniqueNewDivaNr)) {
227
237
  _context2.next = 3;
228
238
  break;
229
239
  }
@@ -290,7 +300,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
290
300
  }
291
301
  throw new Error('If existing products are fetched, there has to be atleast a base product.');
292
302
  case 25:
293
- dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct); //to remember what for position was previously set for the classification
303
+ 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;
304
+ if (!(!((_baseProduct2 = baseProduct) !== null && _baseProduct2 !== void 0 && _baseProduct2.divaNr) && getUniqueNewDivaNr)) {
305
+ _context2.next = 30;
306
+ break;
307
+ }
308
+ _context2.next = 29;
309
+ return this.apiGetUniqueDivaNr();
310
+ case 29:
311
+ myDivaNr = _context2.sent;
312
+ case 30:
313
+ dataByBasket = this.getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct, getUniqueNewDivaNr ? myDivaNr : undefined); //to remember what for position was previously set for the classification
294
314
  oldClassificationData = {};
295
315
  for (i = 0; i < products.data.length; i++) {
296
316
  variant = products.data[i];
@@ -301,27 +321,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
301
321
  }
302
322
  }
303
323
  }
304
- oldUniqueHash = (_baseProduct = baseProduct) === null || _baseProduct === void 0 ? void 0 : _baseProduct.uniqueHash;
305
- 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;
324
+ oldUniqueHash = (_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3.uniqueHash;
325
+ 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;
326
+ if (getUniqueNewDivaNr && myDivaNr) {
327
+ configuration = _objectSpread(_objectSpread({}, configuration), {}, {
328
+ DivaNr: myDivaNr
329
+ });
330
+ }
306
331
  baseData = _objectSpread(_objectSpread(_objectSpread({}, dataByBasket), baseProduct), {}, {
307
- _id: ((_baseProduct3 = baseProduct) === null || _baseProduct3 === void 0 ? void 0 : _baseProduct3._id) || nanoid(),
308
- 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,
309
- 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,
310
- 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,
311
- 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,
332
+ _id: ((_baseProduct5 = baseProduct) === null || _baseProduct5 === void 0 ? void 0 : _baseProduct5._id) || nanoid(),
333
+ divaNr: myDivaNr,
334
+ 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,
335
+ 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,
336
+ 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,
312
337
  configuration: configuration,
313
- dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct8 = baseProduct) === null || _baseProduct8 === void 0 ? void 0 : _baseProduct8.dockingPoints,
338
+ dockingPoints: (_dataByBasket$docking = dataByBasket.dockingPoints) !== null && _dataByBasket$docking !== void 0 ? _dataByBasket$docking : (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.dockingPoints,
314
339
  currency: DivaUtils.defaultPriceFormat.currency,
315
- organizationId: (_baseProduct$organiza = (_baseProduct9 = baseProduct) === null || _baseProduct9 === void 0 ? void 0 : _baseProduct9.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
340
+ organizationId: (_baseProduct$organiza = (_baseProduct10 = baseProduct) === null || _baseProduct10 === void 0 ? void 0 : _baseProduct10.organizationId) !== null && _baseProduct$organiza !== void 0 ? _baseProduct$organiza : this.organization._id,
316
341
  inheritedOrganizations: [].concat(_toConsumableArray((_this$organization$pa = (_this$organization$pa2 = this.organization.parentOrganizations) === null || _this$organization$pa2 === void 0 ? void 0 : _this$organization$pa2.map(function (o) {
317
342
  return o._id;
318
343
  })) !== null && _this$organization$pa !== void 0 ? _this$organization$pa : []), [this.organization._id]),
319
- 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,
320
- createdBy_displayText: (_baseProduct11 = baseProduct) === null || _baseProduct11 === void 0 ? void 0 : _baseProduct11.createdBy_displayText,
321
- archived: (_baseProduct12 = baseProduct) !== null && _baseProduct12 !== void 0 && _baseProduct12.archived ? (_baseProduct13 = baseProduct) === null || _baseProduct13 === void 0 ? void 0 : _baseProduct13.archived : false,
322
- isTopseller: !!((_baseProduct14 = baseProduct) !== null && _baseProduct14 !== void 0 && _baseProduct14.isTopseller),
323
- orderText: (_dataByBasket$orderTe = dataByBasket.orderText) !== null && _dataByBasket$orderTe !== void 0 ? _dataByBasket$orderTe : (_baseProduct15 = baseProduct) === null || _baseProduct15 === void 0 ? void 0 : _baseProduct15.orderText,
324
- technicalDescription: (_dataByBasket$technic = dataByBasket.technicalDescription) !== null && _dataByBasket$technic !== void 0 ? _dataByBasket$technic : (_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16.technicalDescription
344
+ 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,
345
+ createdBy_displayText: (_baseProduct12 = baseProduct) === null || _baseProduct12 === void 0 ? void 0 : _baseProduct12.createdBy_displayText,
346
+ archived: (_baseProduct13 = baseProduct) !== null && _baseProduct13 !== void 0 && _baseProduct13.archived ? (_baseProduct14 = baseProduct) === null || _baseProduct14 === void 0 ? void 0 : _baseProduct14.archived : false,
347
+ isTopseller: !!((_baseProduct15 = baseProduct) !== null && _baseProduct15 !== void 0 && _baseProduct15.isTopseller),
348
+ orderText: (_dataByBasket$orderTe = dataByBasket.orderText) !== null && _dataByBasket$orderTe !== void 0 ? _dataByBasket$orderTe : (_baseProduct16 = baseProduct) === null || _baseProduct16 === void 0 ? void 0 : _baseProduct16.orderText,
349
+ technicalDescription: (_dataByBasket$technic = dataByBasket.technicalDescription) !== null && _dataByBasket$technic !== void 0 ? _dataByBasket$technic : (_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.technicalDescription
325
350
  });
326
351
  metaData = basket === null || basket === void 0 ? void 0 : basket.OrderSets.reduce(function (prev, curr) {
327
352
  return _objectSpread(_objectSpread({}, prev), curr.MetaData || {});
@@ -330,7 +355,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
330
355
  return _objectSpread(_objectSpread({}, prev), curr.MetaData_locales || {});
331
356
  }, {});
332
357
  _this$parseMetaDataAn = this.parseMetaDataAndClassificationInformation(metaData, metaData_locales, baseProduct, classificationConfig, customBaseFields), classificationData = _this$parseMetaDataAn.classificationData, customData = _this$parseMetaDataAn.customData, optMap = _this$parseMetaDataAn.optMap;
333
- baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct17 = baseProduct) === null || _baseProduct17 === void 0 ? void 0 : _baseProduct17.customData), customData);
358
+ baseData.customData = _objectSpread(_objectSpread({}, (_baseProduct18 = baseProduct) === null || _baseProduct18 === void 0 ? void 0 : _baseProduct18.customData), customData);
334
359
 
335
360
  //add livingarea,maincategorie,subcategorie of loaded product if not exists
336
361
  classificationConfig = this.checkAndAddClassificationConfigCategories(baseProduct, classificationConfig);
@@ -347,11 +372,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
347
372
  optFields = [];
348
373
  initialSelectedFields = [];
349
374
  if (!dataByBasket.isSet) {
350
- _context2.next = 46;
375
+ _context2.next = 52;
351
376
  break;
352
377
  }
353
378
  throw new Error('Variants are currently not supported for set products');
354
- case 46:
379
+ case 52:
355
380
  //iterate all existing variant products and add them to the variants
356
381
  usedVariantIds = [];
357
382
  variantProducts.forEach(function (product) {
@@ -407,7 +432,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
407
432
  }
408
433
 
409
434
  //get opt data
410
- 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) {
435
+ 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) {
411
436
  var _ref5 = _slicedToArray(_ref4, 2);
412
437
  _ref5[0];
413
438
  var value = _ref5[1];
@@ -482,7 +507,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
482
507
  availableLanguages: availableLanguages,
483
508
  currentLang: currentLang
484
509
  });
485
- case 59:
510
+ case 65:
486
511
  case "end":
487
512
  return _context2.stop();
488
513
  }
@@ -495,7 +520,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
495
520
  }())
496
521
  }, {
497
522
  key: "getProductDataByBasket",
498
- value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct) {
523
+ value: function getProductDataByBasket(basket, catalogData, fieldConfiguration, baseProduct, customDivaNr) {
499
524
  var dataByBasket = {};
500
525
  var isSet = !!(basket !== null && basket !== void 0 && basket.SetPlannerInfos);
501
526
  dataByBasket.isSet = isSet;
@@ -671,7 +696,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
671
696
  }).filter(function (f) {
672
697
  return f;
673
698
  });
674
- dataByBasket.orderText = basket.getEKText(true);
699
+ dataByBasket.orderText = basket.getEKText(true, customDivaNr);
675
700
  dataByBasket.uniqueHash = isSet ? ProductHandlerAbstract.getHashValue(basket.OrderSets.map(function (os) {
676
701
  return os.SetHash;
677
702
  }).join(''), basket.Diva3DProject) : ProductHandlerAbstract.getHashValue(basket.SetHash, basket.Diva3DProject);
@@ -825,10 +850,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
825
850
  this.trimStrings(baseData);
826
851
  //the base product is constructed, based on baseData and classification data
827
852
  baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev, _ref13) {
853
+ var _fieldConfiguration$c;
828
854
  var _ref14 = _slicedToArray(_ref13, 2),
829
855
  key = _ref14[0],
830
856
  value = _ref14[1];
831
- prev["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.classMap[key].values);
857
+ 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);
832
858
  return prev;
833
859
  }, {})), {}, {
834
860
  _id: originProductId && !(variantData !== null && variantData !== void 0 && variantData.length) ? originProductId : baseData._id,
@@ -858,11 +884,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
858
884
  var value = _ref18[1];
859
885
  return value;
860
886
  }).forEach(function (_ref19) {
861
- var _baseProduct19;
887
+ var _baseProduct20;
862
888
  var _ref20 = _slicedToArray(_ref19, 2),
863
889
  key = _ref20[0],
864
890
  value = _ref20[1];
865
- return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct19 = baseProduct["dc_".concat(key)]) !== null && _baseProduct19 !== void 0 ? _baseProduct19 : {}), {}, {
891
+ return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct20 = baseProduct["dc_".concat(key)]) !== null && _baseProduct20 !== void 0 ? _baseProduct20 : {}), {}, {
866
892
  opt: value.field
867
893
  });
868
894
  });
@@ -1264,6 +1290,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1264
1290
  if (isManual) {
1265
1291
  addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
1266
1292
  }
1293
+ var discountedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.discountedPrice;
1294
+ var noDiscountManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.discountedPrice) === undefined && (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.percentageDiscount) === 0;
1295
+ if (noDiscountManual) {
1296
+ discountedPrice = undefined;
1297
+ }
1267
1298
  var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
1268
1299
  classificationData = _this$parseMetaDataAn2.classificationData,
1269
1300
  customData = _this$parseMetaDataAn2.customData;
@@ -1287,6 +1318,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1287
1318
  //only if cv is not defined fallback to the values in product
1288
1319
  addedPrice: addedPrice,
1289
1320
  calculatedPrice: price.calculatedPrice,
1321
+ discountedPrice: discountedPrice,
1290
1322
  variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
1291
1323
  image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
1292
1324
  image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
@@ -1957,12 +1989,62 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1957
1989
  return apiMarkAsFavorite;
1958
1990
  }()
1959
1991
  }, {
1960
- key: "apiDeleteProducts",
1992
+ key: "apiGetUniqueDivaNr",
1961
1993
  value: function () {
1962
- var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(products) {
1963
- var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
1994
+ var _apiGetUniqueDivaNr = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
1995
+ var _res5;
1996
+ var fullUrl, res, resData;
1964
1997
  return _regeneratorRuntime.wrap(function _callee12$(_context14) {
1965
1998
  while (1) switch (_context14.prev = _context14.next) {
1999
+ case 0:
2000
+ fullUrl = new URL(this.basketService + '/baskets/uniqueDivaNr');
2001
+ _context14.prev = 1;
2002
+ _context14.next = 4;
2003
+ return axios.get(fullUrl.toString(), {
2004
+ headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
2005
+ 'Content-Type': 'application/json'
2006
+ })
2007
+ });
2008
+ case 4:
2009
+ res = _context14.sent;
2010
+ _context14.next = 7;
2011
+ return res.data;
2012
+ case 7:
2013
+ resData = _context14.sent;
2014
+ _context14.next = 13;
2015
+ break;
2016
+ case 10:
2017
+ _context14.prev = 10;
2018
+ _context14.t0 = _context14["catch"](1);
2019
+ throw new Error('Error on activate product', {
2020
+ cause: _context14.t0
2021
+ });
2022
+ case 13:
2023
+ if (!(((_res5 = res) === null || _res5 === void 0 ? void 0 : _res5.status) == 200)) {
2024
+ _context14.next = 15;
2025
+ break;
2026
+ }
2027
+ return _context14.abrupt("return", resData.divaNr);
2028
+ case 15:
2029
+ throw new Error(resData.error);
2030
+ case 16:
2031
+ case "end":
2032
+ return _context14.stop();
2033
+ }
2034
+ }, _callee12, this, [[1, 10]]);
2035
+ }));
2036
+ function apiGetUniqueDivaNr() {
2037
+ return _apiGetUniqueDivaNr.apply(this, arguments);
2038
+ }
2039
+ return apiGetUniqueDivaNr;
2040
+ }()
2041
+ }, {
2042
+ key: "apiDeleteProducts",
2043
+ value: function () {
2044
+ var _apiDeleteProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(products) {
2045
+ var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
2046
+ return _regeneratorRuntime.wrap(function _callee13$(_context15) {
2047
+ while (1) switch (_context15.prev = _context15.next) {
1966
2048
  case 0:
1967
2049
  fullUrl = this.catalogService + '/products';
1968
2050
  fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
@@ -1973,7 +2055,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1973
2055
  i = 0;
1974
2056
  case 5:
1975
2057
  if (!(i < productsInChunks.length)) {
1976
- _context14.next = 13;
2058
+ _context15.next = 13;
1977
2059
  break;
1978
2060
  }
1979
2061
  promises = productsInChunks[i].map(function (p) {
@@ -1995,17 +2077,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1995
2077
  title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
1996
2078
  dontRenderForm: true
1997
2079
  });
1998
- _context14.next = 10;
2080
+ _context15.next = 10;
1999
2081
  return Promise.all(promises);
2000
2082
  case 10:
2001
2083
  i++;
2002
- _context14.next = 5;
2084
+ _context15.next = 5;
2003
2085
  break;
2004
2086
  case 13:
2005
2087
  case "end":
2006
- return _context14.stop();
2088
+ return _context15.stop();
2007
2089
  }
2008
- }, _callee12, this);
2090
+ }, _callee13, this);
2009
2091
  }));
2010
2092
  function apiDeleteProducts(_x20) {
2011
2093
  return _apiDeleteProducts.apply(this, arguments);
@@ -2024,13 +2106,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2024
2106
  }, {
2025
2107
  key: "apiLoadProductVariantsGrouped",
2026
2108
  value: function () {
2027
- var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref45) {
2109
+ var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref45) {
2028
2110
  var limit, skip, fields, _ref45$search, search, sort, favorites, abortController, fullUrl, headers, promise;
2029
- return _regeneratorRuntime.wrap(function _callee13$(_context15) {
2030
- while (1) switch (_context15.prev = _context15.next) {
2111
+ return _regeneratorRuntime.wrap(function _callee14$(_context16) {
2112
+ while (1) switch (_context16.prev = _context16.next) {
2031
2113
  case 0:
2032
2114
  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;
2033
- 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.fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search ? '&search=' + DivaUtils.fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils.fixedEncodeURIComponent(sort) : '') + (favorites ? '&favorites=true' : '');
2115
+ 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.fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search.length ? '&search=' + DivaUtils.fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils.fixedEncodeURIComponent(sort) : '') + (favorites ? '&favorites=true' : '');
2034
2116
  headers = {
2035
2117
  'Content-Type': 'application/json'
2036
2118
  };
@@ -2051,15 +2133,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2051
2133
  reject('Error loading products grouped by variants: ' + error.message);
2052
2134
  });
2053
2135
  });
2054
- _context15.next = 7;
2136
+ _context16.next = 7;
2055
2137
  return promise;
2056
2138
  case 7:
2057
- return _context15.abrupt("return", _context15.sent);
2139
+ return _context16.abrupt("return", _context16.sent);
2058
2140
  case 8:
2059
2141
  case "end":
2060
- return _context15.stop();
2142
+ return _context16.stop();
2061
2143
  }
2062
- }, _callee13, this);
2144
+ }, _callee14, this);
2063
2145
  }));
2064
2146
  function apiLoadProductVariantsGrouped(_x21) {
2065
2147
  return _apiLoadProductVariantsGrouped.apply(this, arguments);
@@ -2069,46 +2151,46 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2069
2151
  }, {
2070
2152
  key: "apiSaveProducts",
2071
2153
  value: function () {
2072
- var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2154
+ var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2073
2155
  var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, _i2, _loop3, j;
2074
- return _regeneratorRuntime.wrap(function _callee14$(_context17) {
2075
- while (1) switch (_context17.prev = _context17.next) {
2156
+ return _regeneratorRuntime.wrap(function _callee15$(_context18) {
2157
+ while (1) switch (_context18.prev = _context18.next) {
2076
2158
  case 0:
2077
2159
  fullUrl = serverUrl + '/v1/products/groups';
2078
- BATCH_SIZE = 40;
2160
+ BATCH_SIZE = 10;
2079
2161
  productsPackages = [];
2080
2162
  groupIndex = 0;
2081
2163
  i = 0;
2082
2164
  case 5:
2083
2165
  if (!(i < products.length)) {
2084
- _context17.next = 15;
2166
+ _context18.next = 15;
2085
2167
  break;
2086
2168
  }
2087
2169
  if (!products[i].baseProduct) {
2088
- _context17.next = 9;
2170
+ _context18.next = 9;
2089
2171
  break;
2090
2172
  }
2091
2173
  baseProduct = products[i];
2092
- return _context17.abrupt("continue", 12);
2174
+ return _context18.abrupt("continue", 12);
2093
2175
  case 9:
2094
2176
  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++;
2095
2177
  if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
2096
2178
  productsPackages[groupIndex].push(products[i]);
2097
2179
  case 12:
2098
2180
  i++;
2099
- _context17.next = 5;
2181
+ _context18.next = 5;
2100
2182
  break;
2101
2183
  case 15:
2102
2184
  responseProducts = [];
2103
2185
  _i2 = 0;
2104
2186
  case 17:
2105
2187
  if (!(_i2 < productsPackages.length)) {
2106
- _context17.next = 40;
2188
+ _context18.next = 40;
2107
2189
  break;
2108
2190
  }
2109
- if (baseProduct) productsPackages[_i2].unshift(baseProduct);
2110
- _context17.prev = 19;
2111
- _context17.next = 22;
2191
+ if (baseProduct && _i2 == 0) productsPackages[_i2].unshift(baseProduct);
2192
+ _context18.prev = 19;
2193
+ _context18.next = 22;
2112
2194
  return fetch(fullUrl, {
2113
2195
  method: 'PUT',
2114
2196
  headers: {
@@ -2128,23 +2210,23 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2128
2210
  return res.json();
2129
2211
  });
2130
2212
  case 22:
2131
- response = _context17.sent;
2213
+ response = _context18.sent;
2132
2214
  if (!response.Error) {
2133
- _context17.next = 25;
2215
+ _context18.next = 25;
2134
2216
  break;
2135
2217
  }
2136
2218
  throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
2137
2219
  case 25:
2138
- _context17.next = 30;
2220
+ _context18.next = 30;
2139
2221
  break;
2140
2222
  case 27:
2141
- _context17.prev = 27;
2142
- _context17.t0 = _context17["catch"](19);
2223
+ _context18.prev = 27;
2224
+ _context18.t0 = _context18["catch"](19);
2143
2225
  throw Error(status);
2144
2226
  case 30:
2145
2227
  _loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop3(j) {
2146
- return _regeneratorRuntime.wrap(function _loop3$(_context16) {
2147
- while (1) switch (_context16.prev = _context16.next) {
2228
+ return _regeneratorRuntime.wrap(function _loop3$(_context17) {
2229
+ while (1) switch (_context17.prev = _context17.next) {
2148
2230
  case 0:
2149
2231
  if (response.products[j].baseProduct) baseProduct = response.products[j];
2150
2232
  if (!responseProducts.find(function (p) {
@@ -2154,32 +2236,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2154
2236
  }
2155
2237
  case 2:
2156
2238
  case "end":
2157
- return _context16.stop();
2239
+ return _context17.stop();
2158
2240
  }
2159
2241
  }, _loop3);
2160
2242
  });
2161
2243
  j = 0;
2162
2244
  case 32:
2163
2245
  if (!(j < response.products.length)) {
2164
- _context17.next = 37;
2246
+ _context18.next = 37;
2165
2247
  break;
2166
2248
  }
2167
- return _context17.delegateYield(_loop3(j), "t1", 34);
2249
+ return _context18.delegateYield(_loop3(j), "t1", 34);
2168
2250
  case 34:
2169
2251
  j++;
2170
- _context17.next = 32;
2252
+ _context18.next = 32;
2171
2253
  break;
2172
2254
  case 37:
2173
2255
  _i2++;
2174
- _context17.next = 17;
2256
+ _context18.next = 17;
2175
2257
  break;
2176
2258
  case 40:
2177
- return _context17.abrupt("return", responseProducts);
2259
+ return _context18.abrupt("return", responseProducts);
2178
2260
  case 41:
2179
2261
  case "end":
2180
- return _context17.stop();
2262
+ return _context18.stop();
2181
2263
  }
2182
- }, _callee14, null, [[19, 27]]);
2264
+ }, _callee15, null, [[19, 27]]);
2183
2265
  }));
2184
2266
  function apiSaveProducts(_x22, _x23, _x24, _x25, _x26) {
2185
2267
  return _apiSaveProducts.apply(this, arguments);
@@ -2406,10 +2488,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2406
2488
  }, {
2407
2489
  key: "loadSelectOptions",
2408
2490
  value: function () {
2409
- var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
2491
+ var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee16(sessionGuid, dataSource, additionalFilter) {
2410
2492
  var values, apiUrl, i, apiResult, _i3, value, text;
2411
- return _regeneratorRuntime.wrap(function _callee15$(_context18) {
2412
- while (1) switch (_context18.prev = _context18.next) {
2493
+ return _regeneratorRuntime.wrap(function _callee16$(_context19) {
2494
+ while (1) switch (_context19.prev = _context19.next) {
2413
2495
  case 0:
2414
2496
  values = [];
2415
2497
  apiUrl = dataSource.url;
@@ -2418,7 +2500,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2418
2500
  apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
2419
2501
  }
2420
2502
  }
2421
- _context18.next = 5;
2503
+ _context19.next = 5;
2422
2504
  return fetch(apiUrl, {
2423
2505
  headers: {
2424
2506
  sessionGuid: sessionGuid
@@ -2430,7 +2512,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2430
2512
  return res.json();
2431
2513
  });
2432
2514
  case 5:
2433
- apiResult = _context18.sent;
2515
+ apiResult = _context19.sent;
2434
2516
  if (dataSource.useKey) {
2435
2517
  apiResult = apiResult[dataSource.useKey];
2436
2518
  }
@@ -2442,12 +2524,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2442
2524
  text: text
2443
2525
  });
2444
2526
  }
2445
- return _context18.abrupt("return", values);
2527
+ return _context19.abrupt("return", values);
2446
2528
  case 9:
2447
2529
  case "end":
2448
- return _context18.stop();
2530
+ return _context19.stop();
2449
2531
  }
2450
- }, _callee15);
2532
+ }, _callee16);
2451
2533
  }));
2452
2534
  function loadSelectOptions(_x27, _x28, _x29) {
2453
2535
  return _loadSelectOptions.apply(this, arguments);
@@ -2483,7 +2565,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2483
2565
  OPV: v.OPV,
2484
2566
  OPTName: opt.Name,
2485
2567
  OPVName: opv.Name,
2486
- OPVImage: catalog.mediaUrl + opv.Image
2568
+ OPVImage: opv.Image ? catalog.mediaUrl + opv.Image : undefined
2487
2569
  });
2488
2570
  }
2489
2571
  }
@@ -22,6 +22,7 @@ export interface LoadProductsParams {
22
22
  classificationConfig?: ClassificationData;
23
23
  availableLanguages?: string[];
24
24
  currentLang?: string;
25
+ getUniqueNewDivaNr?: boolean;
25
26
  }
26
27
  export interface PrepareDataParams {
27
28
  basket?: BasketData;
@@ -68,6 +69,7 @@ export declare class ProductHandlerAbstract {
68
69
  private _apiKey?;
69
70
  private _catalogService;
70
71
  private _mediaService;
72
+ private _basketService;
71
73
  private _api2;
72
74
  private _sessionGuid?;
73
75
  private _organization;
@@ -75,6 +77,8 @@ export declare class ProductHandlerAbstract {
75
77
  set langs(val: string[]);
76
78
  set catalogService(val: string);
77
79
  get catalogService(): string;
80
+ set basketService(val: string);
81
+ get basketService(): string;
78
82
  set mediaService(val: string);
79
83
  get mediaService(): string;
80
84
  get api2(): string;
@@ -102,7 +106,7 @@ export declare class ProductHandlerAbstract {
102
106
  * @param catalogServiceUrl the url for the catalog service
103
107
  * @param productData an optional list of products, if set no products get loaded from the server
104
108
  */
105
- loadProducts({ basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, availableLanguages, currentLang, }: LoadProductsParams): Promise<{
109
+ loadProducts({ basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, availableLanguages, currentLang, getUniqueNewDivaNr, }: LoadProductsParams): Promise<{
106
110
  baseData: ProductDataAbstract;
107
111
  classificationData: any;
108
112
  optFields: OPTValueField[];
@@ -237,6 +241,7 @@ export declare class ProductHandlerAbstract {
237
241
  data: any[];
238
242
  }>;
239
243
  apiMarkAsFavorite(id: string, organizationId: string): Promise<void>;
244
+ apiGetUniqueDivaNr(): Promise<any>;
240
245
  static loadSelectOptions(sessionGuid: string, dataSource: DataSourceApi, additionalFilter?: [{
241
246
  key: string;
242
247
  value: string;