@azzas/azzas-tracker-web 2.0.0-preview.3 → 2.0.0-preview.4

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.
@@ -1308,8 +1308,15 @@ var AzzasTracker = function() {
1308
1308
  });
1309
1309
  })();
1310
1310
  };
1311
- var getItemShippingTier2 = function getItemShippingTier2() {
1312
- return null;
1311
+ var getItemShippingTier2 = function getItemShippingTier2(orderForm, item) {
1312
+ var _orderForm_shippingData_logisticsInfo, _orderForm_shippingData, _info_slas, _selectedSla_pickupStoreInfo;
1313
+ var info = orderForm === null || orderForm === void 0 ? void 0 : (_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : (_orderForm_shippingData_logisticsInfo = _orderForm_shippingData.logisticsInfo) === null || _orderForm_shippingData_logisticsInfo === void 0 ? void 0 : _orderForm_shippingData_logisticsInfo.find(function(li) {
1314
+ return li.itemId === item.id;
1315
+ });
1316
+ var selectedSla = info === null || info === void 0 ? void 0 : (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.find(function(sla) {
1317
+ return sla.id === info.selectedSla;
1318
+ });
1319
+ return (selectedSla === null || selectedSla === void 0 ? void 0 : (_selectedSla_pickupStoreInfo = selectedSla.pickupStoreInfo) === null || _selectedSla_pickupStoreInfo === void 0 ? void 0 : _selectedSla_pickupStoreInfo.friendlyName) ? "retirada em loja: ".concat(selectedSla.pickupStoreInfo.friendlyName) : (selectedSla === null || selectedSla === void 0 ? void 0 : selectedSla.name) ? "Receba em casa: ".concat(selectedSla.name) : null;
1313
1320
  };
1314
1321
  var getParameters = function getParameters(context, eventName) {
1315
1322
  return _async_to_generator(function() {
@@ -2505,7 +2512,7 @@ var AzzasTracker = function() {
2505
2512
  // cor
2506
2513
  item_variant2: (_ref3 = item === null || item === void 0 ? void 0 : (_item_name1 = item.name) === null || _item_name1 === void 0 ? void 0 : _item_name1.split(" - ")[1]) !== null && _ref3 !== void 0 ? _ref3 : null,
2507
2514
  // tamanho
2508
- item_shipping_tier: getItemShippingTier2(),
2515
+ item_shipping_tier: "",
2509
2516
  item_ref: (_ref4 = (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : (_item_additionalProperty_find = _item_additionalProperty.find(function(i) {
2510
2517
  return i.name === "RefId";
2511
2518
  })) === null || _item_additionalProperty_find === void 0 ? void 0 : (_item_additionalProperty_find_value = _item_additionalProperty_find.value) === null || _item_additionalProperty_find_value === void 0 ? void 0 : _item_additionalProperty_find_value.replace(/_\d+$/, "")) !== null && _ref4 !== void 0 ? _ref4 : null,
@@ -2622,7 +2629,7 @@ var AzzasTracker = function() {
2622
2629
  discount: ((item === null || item === void 0 ? void 0 : item.listPrice) - (item === null || item === void 0 ? void 0 : item.sellingPrice)) / 100,
2623
2630
  item_variant: (_ref5 = item === null || item === void 0 ? void 0 : (_item_skuName = item.skuName) === null || _item_skuName === void 0 ? void 0 : (_item_skuName_split_ = _item_skuName.split(" - ")[0]) === null || _item_skuName_split_ === void 0 ? void 0 : (_item_skuName_split__split_pop = _item_skuName_split_.split("_").pop()) === null || _item_skuName_split__split_pop === void 0 ? void 0 : _item_skuName_split__split_pop.trim()) !== null && _ref5 !== void 0 ? _ref5 : null,
2624
2631
  item_variant2: (_ref6 = item === null || item === void 0 ? void 0 : (_item_skuName1 = item.skuName) === null || _item_skuName1 === void 0 ? void 0 : (_item_skuName_split_1 = _item_skuName1.split(" - ")[1]) === null || _item_skuName_split_1 === void 0 ? void 0 : _item_skuName_split_1.trim()) !== null && _ref6 !== void 0 ? _ref6 : null,
2625
- item_shipping_tier: "",
2632
+ item_shipping_tier: getItemShippingTier2(context.orderForm, item),
2626
2633
  item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
2627
2634
  item_category: (_getItemCategory5 = getItemCategory5(item)) !== null && _getItemCategory5 !== void 0 ? _getItemCategory5 : null,
2628
2635
  item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
@@ -2669,10 +2676,10 @@ var AzzasTracker = function() {
2669
2676
  payment_type: getPaymentType,
2670
2677
  total_discount: function(context) {
2671
2678
  var _context_orderForm, _context_orderForm1;
2672
- if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
2673
- var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
2674
- var items = context.orderForm.items;
2675
- var totalDiscount = items.reduce(function(acc, item) {
2679
+ if (context === null || context === void 0 ? void 0 : context.total_discount) return context.total_discount;
2680
+ if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
2681
+ var totalsList = ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totalizers) || [];
2682
+ var totalDiscount = getOrderFormItems(context.orderForm).reduce(function(acc, item) {
2676
2683
  var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
2677
2684
  return acc + unitDiscount * item.quantity;
2678
2685
  }, 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azzas/azzas-tracker-web",
3
- "version": "2.0.0-preview.3",
3
+ "version": "2.0.0-preview.4",
4
4
  "type": "module",
5
5
  "main": "./dist/mod.cjs",
6
6
  "module": "./dist/mod.js",