@crystaldesign/product-handler 24.15.0-beta.9 → 24.15.0-rc.0

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
  });
@@ -1023,7 +1049,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1023
1049
  preparedProduct = {
1024
1050
  parent: baseProduct._id,
1025
1051
  baseProduct: false,
1026
- _id: productId
1052
+ _id: productId,
1053
+ organizationId: baseProduct.organizationId
1027
1054
  };
1028
1055
  }
1029
1056
  configuration = (_basket$getProductCon2 = basket === null || basket === void 0 ? void 0 : basket.getProductConfiguration(typeof vd.variantId == 'string' ? Number(vd.variantId) : vd.variantId)) !== null && _basket$getProductCon2 !== void 0 ? _basket$getProductCon2 : vd.configuration;
@@ -1282,6 +1309,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1282
1309
  if (isManual) {
1283
1310
  addedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.addedPrice;
1284
1311
  }
1312
+ var discountedPrice = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.discountedPrice;
1313
+ var noDiscountManual = (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.discountedPrice) === undefined && (variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.percentageDiscount) === 0;
1314
+ if (noDiscountManual) {
1315
+ discountedPrice = undefined;
1316
+ }
1285
1317
  var _this$parseMetaDataAn2 = this.parseMetaDataAndClassificationInformation(MetaData !== null && MetaData !== void 0 ? MetaData : {}, MetaData_locales, variantProduct, classificationConfig, customBaseFields),
1286
1318
  classificationData = _this$parseMetaDataAn2.classificationData,
1287
1319
  customData = _this$parseMetaDataAn2.customData;
@@ -1305,6 +1337,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1305
1337
  //only if cv is not defined fallback to the values in product
1306
1338
  addedPrice: addedPrice,
1307
1339
  calculatedPrice: price.calculatedPrice,
1340
+ discountedPrice: discountedPrice,
1308
1341
  variantId: VariantID !== null && VariantID !== void 0 ? VariantID : parsedProduct.variantId,
1309
1342
  image: SetImage !== null && SetImage !== void 0 ? SetImage : parsedProduct.image,
1310
1343
  image2D: Set2DImage !== null && Set2DImage !== void 0 ? Set2DImage : parsedProduct.image2D,
@@ -1975,12 +2008,62 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1975
2008
  return apiMarkAsFavorite;
1976
2009
  }()
1977
2010
  }, {
1978
- key: "apiDeleteProducts",
2011
+ key: "apiGetUniqueDivaNr",
1979
2012
  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;
2013
+ var _apiGetUniqueDivaNr = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12() {
2014
+ var _res5;
2015
+ var fullUrl, res, resData;
1982
2016
  return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context14) {
1983
2017
  while (1) switch (_context14.prev = _context14.next) {
2018
+ case 0:
2019
+ fullUrl = new URL(this.basketService + '/baskets/uniqueDivaNr');
2020
+ _context14.prev = 1;
2021
+ _context14.next = 4;
2022
+ return axios__default["default"].get(fullUrl.toString(), {
2023
+ headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
2024
+ 'Content-Type': 'application/json'
2025
+ })
2026
+ });
2027
+ case 4:
2028
+ res = _context14.sent;
2029
+ _context14.next = 7;
2030
+ return res.data;
2031
+ case 7:
2032
+ resData = _context14.sent;
2033
+ _context14.next = 13;
2034
+ break;
2035
+ case 10:
2036
+ _context14.prev = 10;
2037
+ _context14.t0 = _context14["catch"](1);
2038
+ throw new Error('Error on activate product', {
2039
+ cause: _context14.t0
2040
+ });
2041
+ case 13:
2042
+ if (!(((_res5 = res) === null || _res5 === void 0 ? void 0 : _res5.status) == 200)) {
2043
+ _context14.next = 15;
2044
+ break;
2045
+ }
2046
+ return _context14.abrupt("return", resData.divaNr);
2047
+ case 15:
2048
+ throw new Error(resData.error);
2049
+ case 16:
2050
+ case "end":
2051
+ return _context14.stop();
2052
+ }
2053
+ }, _callee12, this, [[1, 10]]);
2054
+ }));
2055
+ function apiGetUniqueDivaNr() {
2056
+ return _apiGetUniqueDivaNr.apply(this, arguments);
2057
+ }
2058
+ return apiGetUniqueDivaNr;
2059
+ }()
2060
+ }, {
2061
+ key: "apiDeleteProducts",
2062
+ value: function () {
2063
+ var _apiDeleteProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(products) {
2064
+ var fullUrl, headers, productsInChunks, i, _this$openModal3, _this$t3, promises;
2065
+ return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context15) {
2066
+ while (1) switch (_context15.prev = _context15.next) {
1984
2067
  case 0:
1985
2068
  fullUrl = this.catalogService + '/products';
1986
2069
  fullUrl = "".concat(fullUrl, "?organizationId=").concat(this.organization._id);
@@ -1991,7 +2074,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1991
2074
  i = 0;
1992
2075
  case 5:
1993
2076
  if (!(i < productsInChunks.length)) {
1994
- _context14.next = 13;
2077
+ _context15.next = 13;
1995
2078
  break;
1996
2079
  }
1997
2080
  promises = productsInChunks[i].map(function (p) {
@@ -2013,17 +2096,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2013
2096
  title: (_this$t3 = this.t) === null || _this$t3 === void 0 ? void 0 : _this$t3.call(this, 'productcreator.delete_old_products'),
2014
2097
  dontRenderForm: true
2015
2098
  });
2016
- _context14.next = 10;
2099
+ _context15.next = 10;
2017
2100
  return Promise.all(promises);
2018
2101
  case 10:
2019
2102
  i++;
2020
- _context14.next = 5;
2103
+ _context15.next = 5;
2021
2104
  break;
2022
2105
  case 13:
2023
2106
  case "end":
2024
- return _context14.stop();
2107
+ return _context15.stop();
2025
2108
  }
2026
- }, _callee12, this);
2109
+ }, _callee13, this);
2027
2110
  }));
2028
2111
  function apiDeleteProducts(_x20) {
2029
2112
  return _apiDeleteProducts.apply(this, arguments);
@@ -2042,10 +2125,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2042
2125
  }, {
2043
2126
  key: "apiLoadProductVariantsGrouped",
2044
2127
  value: function () {
2045
- var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(_ref45) {
2128
+ var _apiLoadProductVariantsGrouped = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(_ref45) {
2046
2129
  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) {
2130
+ return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context16) {
2131
+ while (1) switch (_context16.prev = _context16.next) {
2049
2132
  case 0:
2050
2133
  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
2134
  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' : '');
@@ -2069,15 +2152,15 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2069
2152
  reject('Error loading products grouped by variants: ' + error.message);
2070
2153
  });
2071
2154
  });
2072
- _context15.next = 7;
2155
+ _context16.next = 7;
2073
2156
  return promise;
2074
2157
  case 7:
2075
- return _context15.abrupt("return", _context15.sent);
2158
+ return _context16.abrupt("return", _context16.sent);
2076
2159
  case 8:
2077
2160
  case "end":
2078
- return _context15.stop();
2161
+ return _context16.stop();
2079
2162
  }
2080
- }, _callee13, this);
2163
+ }, _callee14, this);
2081
2164
  }));
2082
2165
  function apiLoadProductVariantsGrouped(_x21) {
2083
2166
  return _apiLoadProductVariantsGrouped.apply(this, arguments);
@@ -2087,46 +2170,46 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2087
2170
  }, {
2088
2171
  key: "apiSaveProducts",
2089
2172
  value: function () {
2090
- var _apiSaveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2173
+ var _apiSaveProducts = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee15(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2091
2174
  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) {
2175
+ return _regeneratorRuntime__default["default"].wrap(function _callee15$(_context18) {
2176
+ while (1) switch (_context18.prev = _context18.next) {
2094
2177
  case 0:
2095
2178
  fullUrl = serverUrl + '/v1/products/groups';
2096
- BATCH_SIZE = 40;
2179
+ BATCH_SIZE = 10;
2097
2180
  productsPackages = [];
2098
2181
  groupIndex = 0;
2099
2182
  i = 0;
2100
2183
  case 5:
2101
2184
  if (!(i < products.length)) {
2102
- _context17.next = 15;
2185
+ _context18.next = 15;
2103
2186
  break;
2104
2187
  }
2105
2188
  if (!products[i].baseProduct) {
2106
- _context17.next = 9;
2189
+ _context18.next = 9;
2107
2190
  break;
2108
2191
  }
2109
2192
  baseProduct = products[i];
2110
- return _context17.abrupt("continue", 12);
2193
+ return _context18.abrupt("continue", 12);
2111
2194
  case 9:
2112
2195
  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
2196
  if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
2114
2197
  productsPackages[groupIndex].push(products[i]);
2115
2198
  case 12:
2116
2199
  i++;
2117
- _context17.next = 5;
2200
+ _context18.next = 5;
2118
2201
  break;
2119
2202
  case 15:
2120
2203
  responseProducts = [];
2121
2204
  _i2 = 0;
2122
2205
  case 17:
2123
2206
  if (!(_i2 < productsPackages.length)) {
2124
- _context17.next = 40;
2207
+ _context18.next = 40;
2125
2208
  break;
2126
2209
  }
2127
- if (baseProduct) productsPackages[_i2].unshift(baseProduct);
2128
- _context17.prev = 19;
2129
- _context17.next = 22;
2210
+ if (baseProduct && _i2 == 0) productsPackages[_i2].unshift(baseProduct);
2211
+ _context18.prev = 19;
2212
+ _context18.next = 22;
2130
2213
  return fetch(fullUrl, {
2131
2214
  method: 'PUT',
2132
2215
  headers: {
@@ -2146,23 +2229,23 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2146
2229
  return res.json();
2147
2230
  });
2148
2231
  case 22:
2149
- response = _context17.sent;
2232
+ response = _context18.sent;
2150
2233
  if (!response.Error) {
2151
- _context17.next = 25;
2234
+ _context18.next = 25;
2152
2235
  break;
2153
2236
  }
2154
2237
  throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
2155
2238
  case 25:
2156
- _context17.next = 30;
2239
+ _context18.next = 30;
2157
2240
  break;
2158
2241
  case 27:
2159
- _context17.prev = 27;
2160
- _context17.t0 = _context17["catch"](19);
2242
+ _context18.prev = 27;
2243
+ _context18.t0 = _context18["catch"](19);
2161
2244
  throw Error(status);
2162
2245
  case 30:
2163
2246
  _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) {
2247
+ return _regeneratorRuntime__default["default"].wrap(function _loop3$(_context17) {
2248
+ while (1) switch (_context17.prev = _context17.next) {
2166
2249
  case 0:
2167
2250
  if (response.products[j].baseProduct) baseProduct = response.products[j];
2168
2251
  if (!responseProducts.find(function (p) {
@@ -2172,32 +2255,32 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2172
2255
  }
2173
2256
  case 2:
2174
2257
  case "end":
2175
- return _context16.stop();
2258
+ return _context17.stop();
2176
2259
  }
2177
2260
  }, _loop3);
2178
2261
  });
2179
2262
  j = 0;
2180
2263
  case 32:
2181
2264
  if (!(j < response.products.length)) {
2182
- _context17.next = 37;
2265
+ _context18.next = 37;
2183
2266
  break;
2184
2267
  }
2185
- return _context17.delegateYield(_loop3(j), "t1", 34);
2268
+ return _context18.delegateYield(_loop3(j), "t1", 34);
2186
2269
  case 34:
2187
2270
  j++;
2188
- _context17.next = 32;
2271
+ _context18.next = 32;
2189
2272
  break;
2190
2273
  case 37:
2191
2274
  _i2++;
2192
- _context17.next = 17;
2275
+ _context18.next = 17;
2193
2276
  break;
2194
2277
  case 40:
2195
- return _context17.abrupt("return", responseProducts);
2278
+ return _context18.abrupt("return", responseProducts);
2196
2279
  case 41:
2197
2280
  case "end":
2198
- return _context17.stop();
2281
+ return _context18.stop();
2199
2282
  }
2200
- }, _callee14, null, [[19, 27]]);
2283
+ }, _callee15, null, [[19, 27]]);
2201
2284
  }));
2202
2285
  function apiSaveProducts(_x22, _x23, _x24, _x25, _x26) {
2203
2286
  return _apiSaveProducts.apply(this, arguments);
@@ -2219,14 +2302,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2219
2302
  filter.push("+[".concat(groups[key].filter(function (f) {
2220
2303
  return f.or;
2221
2304
  }).map(function (f) {
2222
- return "{".concat(f.id, ",").concat(f.op, ",").concat(f.value, "}");
2305
+ return "{".concat(f.id, ",").concat(f.op, ",").concat(typeof f.value == 'string' ? "\"".concat(f.value, "\"") : f.value, "}");
2223
2306
  }).join(), "]"));
2224
2307
  }
2225
2308
  }
2226
2309
  filters.filter(function (f) {
2227
2310
  return !f.or;
2228
2311
  }).forEach(function (f) {
2229
- return filter.push("{".concat(f.id, ",").concat(f.op, ",").concat(f.value, "}"));
2312
+ return filter.push("{".concat(f.id, ",").concat(f.op, ",").concat(typeof f.value == 'string' ? "\"".concat(f.value, "\"") : f.value, "}"));
2230
2313
  });
2231
2314
  }
2232
2315
  return "[".concat(filter.join(), "]");
@@ -2424,10 +2507,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2424
2507
  }, {
2425
2508
  key: "loadSelectOptions",
2426
2509
  value: function () {
2427
- var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee15(sessionGuid, dataSource, additionalFilter) {
2510
+ var _loadSelectOptions = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee16(sessionGuid, dataSource, additionalFilter) {
2428
2511
  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) {
2512
+ return _regeneratorRuntime__default["default"].wrap(function _callee16$(_context19) {
2513
+ while (1) switch (_context19.prev = _context19.next) {
2431
2514
  case 0:
2432
2515
  values = [];
2433
2516
  apiUrl = dataSource.url;
@@ -2436,7 +2519,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2436
2519
  apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
2437
2520
  }
2438
2521
  }
2439
- _context18.next = 5;
2522
+ _context19.next = 5;
2440
2523
  return fetch(apiUrl, {
2441
2524
  headers: {
2442
2525
  sessionGuid: sessionGuid
@@ -2448,7 +2531,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2448
2531
  return res.json();
2449
2532
  });
2450
2533
  case 5:
2451
- apiResult = _context18.sent;
2534
+ apiResult = _context19.sent;
2452
2535
  if (dataSource.useKey) {
2453
2536
  apiResult = apiResult[dataSource.useKey];
2454
2537
  }
@@ -2460,12 +2543,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2460
2543
  text: text
2461
2544
  });
2462
2545
  }
2463
- return _context18.abrupt("return", values);
2546
+ return _context19.abrupt("return", values);
2464
2547
  case 9:
2465
2548
  case "end":
2466
- return _context18.stop();
2549
+ return _context19.stop();
2467
2550
  }
2468
- }, _callee15);
2551
+ }, _callee16);
2469
2552
  }));
2470
2553
  function loadSelectOptions(_x27, _x28, _x29) {
2471
2554
  return _loadSelectOptions.apply(this, arguments);