@azzas/azzas-tracker-web 2.0.0-preview.5 → 2.0.0-preview.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mod.cjs +228 -224
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +6 -2
- package/dist/mod.d.ts +6 -2
- package/dist/mod.global.js +227 -224
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +227 -224
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +265 -255
- package/package.json +1 -1
package/dist/mod.vtex.global.js
CHANGED
|
@@ -1350,7 +1350,7 @@ var AzzasTracker = function() {
|
|
|
1350
1350
|
});
|
|
1351
1351
|
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;
|
|
1352
1352
|
};
|
|
1353
|
-
var getParameters = function getParameters(context, eventName) {
|
|
1353
|
+
var getParameters = function getParameters(context, eventName, config2) {
|
|
1354
1354
|
return _async_to_generator(function() {
|
|
1355
1355
|
var _adapters_currentAdapter, eventConfig, currentAdapter, getters, entries;
|
|
1356
1356
|
return _ts_generator(this, function(_state) {
|
|
@@ -1386,7 +1386,7 @@ var AzzasTracker = function() {
|
|
|
1386
1386
|
];
|
|
1387
1387
|
return [
|
|
1388
1388
|
4,
|
|
1389
|
-
getter(context,
|
|
1389
|
+
getter(context, config2)
|
|
1390
1390
|
];
|
|
1391
1391
|
case 1:
|
|
1392
1392
|
return [
|
|
@@ -1410,8 +1410,10 @@ var AzzasTracker = function() {
|
|
|
1410
1410
|
});
|
|
1411
1411
|
})();
|
|
1412
1412
|
};
|
|
1413
|
-
var
|
|
1414
|
-
|
|
1413
|
+
var initTracker = function initTracker(c) {
|
|
1414
|
+
config = c;
|
|
1415
|
+
};
|
|
1416
|
+
var trackWebEvent = function trackWebEvent(event, context) {
|
|
1415
1417
|
return _async_to_generator(function() {
|
|
1416
1418
|
var parameters, err;
|
|
1417
1419
|
return _ts_generator(this, function(_state) {
|
|
@@ -1425,7 +1427,7 @@ var AzzasTracker = function() {
|
|
|
1425
1427
|
]);
|
|
1426
1428
|
return [
|
|
1427
1429
|
4,
|
|
1428
|
-
getParameters(context, event)
|
|
1430
|
+
getParameters(context, event, config)
|
|
1429
1431
|
];
|
|
1430
1432
|
case 1:
|
|
1431
1433
|
parameters = _state.sent();
|
|
@@ -1515,6 +1517,9 @@ var AzzasTracker = function() {
|
|
|
1515
1517
|
default: function() {
|
|
1516
1518
|
return src_default;
|
|
1517
1519
|
},
|
|
1520
|
+
initTracker: function() {
|
|
1521
|
+
return initTracker;
|
|
1522
|
+
},
|
|
1518
1523
|
trackWebEvent: function() {
|
|
1519
1524
|
return trackWebEvent;
|
|
1520
1525
|
}
|
|
@@ -2446,8 +2451,8 @@ var AzzasTracker = function() {
|
|
|
2446
2451
|
pre_filled: function(context) {
|
|
2447
2452
|
return !!context.preFilled;
|
|
2448
2453
|
},
|
|
2449
|
-
currency: function(
|
|
2450
|
-
if (
|
|
2454
|
+
currency: function(_, config2) {
|
|
2455
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.currency) return config2.currency;
|
|
2451
2456
|
return "BRL";
|
|
2452
2457
|
},
|
|
2453
2458
|
slot_per_line: function(context) {
|
|
@@ -2566,8 +2571,8 @@ var AzzasTracker = function() {
|
|
|
2566
2571
|
}
|
|
2567
2572
|
return null;
|
|
2568
2573
|
},
|
|
2569
|
-
brand: function(context) {
|
|
2570
|
-
if (
|
|
2574
|
+
brand: function(context, config2) {
|
|
2575
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
2571
2576
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2572
2577
|
return normalizeBrand2(context.products.map(function(p) {
|
|
2573
2578
|
var _p_brand;
|
|
@@ -2625,237 +2630,8 @@ var AzzasTracker = function() {
|
|
|
2625
2630
|
return null;
|
|
2626
2631
|
}
|
|
2627
2632
|
});
|
|
2628
|
-
// src/params/adapters/orderForm/utils.ts
|
|
2629
|
-
var getItemCategory5 = function(item) {
|
|
2630
|
-
var _text_match;
|
|
2631
|
-
var categories = item === null || item === void 0 ? void 0 : item.productCategories;
|
|
2632
|
-
if (!categories) return "Cole\xE7\xE3o";
|
|
2633
|
-
var text = Object.values(categories).join(" ");
|
|
2634
|
-
var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
|
|
2635
|
-
return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
|
|
2636
|
-
};
|
|
2637
|
-
var getItemCategory23 = function(item) {
|
|
2638
|
-
var _ref, _validHierarchy_;
|
|
2639
|
-
var AVOID_CATEGORIES = /outlet|bazar|sale/i;
|
|
2640
|
-
var categories = Object.values((_ref = item === null || item === void 0 ? void 0 : item.productCategories) !== null && _ref !== void 0 ? _ref : {});
|
|
2641
|
-
var validHierarchy = categories.map(function(c) {
|
|
2642
|
-
return c.trim();
|
|
2643
|
-
}).filter(function(c) {
|
|
2644
|
-
return c && !AVOID_CATEGORIES.test(c);
|
|
2645
|
-
});
|
|
2646
|
-
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
2647
|
-
return capitalize(deepest);
|
|
2648
|
-
};
|
|
2649
|
-
var getOrderFormItems = function(orderForm) {
|
|
2650
|
-
var idSelected = orderForm === null || orderForm === void 0 ? void 0 : orderForm.selected;
|
|
2651
|
-
return idSelected ? orderForm.items.filter(function(item) {
|
|
2652
|
-
return item.id === idSelected;
|
|
2653
|
-
}) : orderForm.items;
|
|
2654
|
-
};
|
|
2655
|
-
// src/params/adapters/orderForm/index.ts
|
|
2656
|
-
var orderFormAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
|
|
2657
|
-
items: function(context) {
|
|
2658
|
-
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2659
|
-
if ((context === null || context === void 0 ? void 0 : context.orderForm) && (context === null || context === void 0 ? void 0 : context.orderForm.items)) {
|
|
2660
|
-
return getOrderFormItems(context.orderForm).map(function(item, index) {
|
|
2661
|
-
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _getItemCategory5, _getItemCategory23, _ref7, _ref8, _item_detailUrl, _resizeVtexImage2, _ref9, _ref10;
|
|
2662
|
-
var _context_orderForm, _item_additionalInfo, _item_skuName_split__split_pop, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _context_orderForm1;
|
|
2663
|
-
return {
|
|
2664
|
-
quantity: (_ref = item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1,
|
|
2665
|
-
index: (_ref1 = (_ref2 = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.index) !== null && _ref2 !== void 0 ? _ref2 : index) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2666
|
-
item_brand: (_ref3 = (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2667
|
-
item_name: (_ref4 = item === null || item === void 0 ? void 0 : item.name.replace(item === null || item === void 0 ? void 0 : item.skuName, "").trim()) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2668
|
-
price: (item === null || item === void 0 ? void 0 : item.price) / 100,
|
|
2669
|
-
discount: ((item === null || item === void 0 ? void 0 : item.listPrice) - (item === null || item === void 0 ? void 0 : item.sellingPrice)) / 100,
|
|
2670
|
-
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,
|
|
2671
|
-
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,
|
|
2672
|
-
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
2673
|
-
item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
2674
|
-
item_category: (_getItemCategory5 = getItemCategory5(item)) !== null && _getItemCategory5 !== void 0 ? _getItemCategory5 : null,
|
|
2675
|
-
item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
|
|
2676
|
-
item_id: (_ref7 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
2677
|
-
item_sku: (_ref8 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref8 !== void 0 ? _ref8 : null,
|
|
2678
|
-
item_url: (_item_detailUrl = item.detailUrl) !== null && _item_detailUrl !== void 0 ? _item_detailUrl : null,
|
|
2679
|
-
image_url: (_resizeVtexImage2 = resizeVtexImage2(item.imageUrl)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
|
|
2680
|
-
seller_id: (_ref9 = item === null || item === void 0 ? void 0 : item.seller) !== null && _ref9 !== void 0 ? _ref9 : null,
|
|
2681
|
-
item_list_name: (_ref10 = context === null || context === void 0 ? void 0 : (_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.item_list_name) !== null && _ref10 !== void 0 ? _ref10 : null
|
|
2682
|
-
};
|
|
2683
|
-
});
|
|
2684
|
-
}
|
|
2685
|
-
return null;
|
|
2686
|
-
},
|
|
2687
|
-
brand: function(context) {
|
|
2688
|
-
var _context_orderForm;
|
|
2689
|
-
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
2690
|
-
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2691
|
-
var brands = getOrderFormItems(context.orderForm).map(function(item) {
|
|
2692
|
-
return item.additionalInfo.brandName;
|
|
2693
|
-
});
|
|
2694
|
-
return normalizeBrand2(brands);
|
|
2695
|
-
},
|
|
2696
|
-
line_items: function(context) {
|
|
2697
|
-
var _context_orderForm;
|
|
2698
|
-
if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
|
|
2699
|
-
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2700
|
-
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2701
|
-
return item === null || item === void 0 ? void 0 : item.productId;
|
|
2702
|
-
}).filter(function(id) {
|
|
2703
|
-
return Boolean(id);
|
|
2704
|
-
});
|
|
2705
|
-
},
|
|
2706
|
-
value: function(context) {
|
|
2707
|
-
var _context_orderForm;
|
|
2708
|
-
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
2709
|
-
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2710
|
-
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2711
|
-
return (item === null || item === void 0 ? void 0 : item.price) / 100 * item.quantity;
|
|
2712
|
-
}).filter(function(price) {
|
|
2713
|
-
return price !== void 0;
|
|
2714
|
-
}).reduce(function(sum, price) {
|
|
2715
|
-
return sum + price;
|
|
2716
|
-
}, 0);
|
|
2717
|
-
},
|
|
2718
|
-
payment_type: getPaymentType,
|
|
2719
|
-
total_discount: function(context) {
|
|
2720
|
-
var _context_orderForm, _context_orderForm1;
|
|
2721
|
-
if (context === null || context === void 0 ? void 0 : context.total_discount) return context.total_discount;
|
|
2722
|
-
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2723
|
-
var totalsList = ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totalizers) || [];
|
|
2724
|
-
var totalDiscount = getOrderFormItems(context.orderForm).reduce(function(acc, item) {
|
|
2725
|
-
var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
2726
|
-
return acc + unitDiscount * item.quantity;
|
|
2727
|
-
}, 0);
|
|
2728
|
-
var discounts = totalsList.find(function(t) {
|
|
2729
|
-
return t.id === "Discounts";
|
|
2730
|
-
});
|
|
2731
|
-
return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
2732
|
-
},
|
|
2733
|
-
subtotal: function(context) {
|
|
2734
|
-
var _context_orderForm, _context_orderForm1;
|
|
2735
|
-
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) || [];
|
|
2736
|
-
var subtotal = totalsList.filter(function(t) {
|
|
2737
|
-
return t.id === "Items";
|
|
2738
|
-
}).reduce(function(acc, t) {
|
|
2739
|
-
return acc + (t.value || 0);
|
|
2740
|
-
}, 0) / 100 || 0;
|
|
2741
|
-
return subtotal;
|
|
2742
|
-
},
|
|
2743
|
-
coupon_message: function(context) {
|
|
2744
|
-
var _context_orderForm;
|
|
2745
|
-
if (context.couponMessage) return context.couponMessage;
|
|
2746
|
-
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
2747
|
-
if (messages.length === 0) return null;
|
|
2748
|
-
var couponMessages = messages.filter(function(msg) {
|
|
2749
|
-
return msg.text.toLowerCase().includes("cupom");
|
|
2750
|
-
});
|
|
2751
|
-
if (couponMessages.length === 0) return null;
|
|
2752
|
-
return couponMessages.map(function(msg) {
|
|
2753
|
-
return msg.text;
|
|
2754
|
-
}).join(" | ");
|
|
2755
|
-
},
|
|
2756
|
-
zipcode: function(context) {
|
|
2757
|
-
var _context_zipcode;
|
|
2758
|
-
return (_context_zipcode = context.zipcode) !== null && _context_zipcode !== void 0 ? _context_zipcode : null;
|
|
2759
|
-
},
|
|
2760
|
-
flag_pickup: function(context) {
|
|
2761
|
-
var _orderForm_shippingData;
|
|
2762
|
-
var orderForm = context.orderForm;
|
|
2763
|
-
if (!orderForm) return null;
|
|
2764
|
-
var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
|
|
2765
|
-
var hasPickup = logisticsInfo.some(function(info) {
|
|
2766
|
-
var _info_slas;
|
|
2767
|
-
return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
|
|
2768
|
-
return sla.deliveryChannel === "pickup-in-point";
|
|
2769
|
-
});
|
|
2770
|
-
});
|
|
2771
|
-
return hasPickup;
|
|
2772
|
-
},
|
|
2773
|
-
shippings: function(context) {
|
|
2774
|
-
if (!context.orderForm) return null;
|
|
2775
|
-
var _context_orderForm = context.orderForm, items = _context_orderForm.items, shippingData = _context_orderForm.shippingData;
|
|
2776
|
-
var acc = {};
|
|
2777
|
-
shippingData.logisticsInfo.forEach(function(param) {
|
|
2778
|
-
var itemIndex = param.itemIndex, slas = param.slas;
|
|
2779
|
-
var item = items[itemIndex];
|
|
2780
|
-
if (!item) return;
|
|
2781
|
-
slas.forEach(function(sla) {
|
|
2782
|
-
if (!acc[sla.name]) acc[sla.name] = {
|
|
2783
|
-
shipping_tier: sla.name,
|
|
2784
|
-
delivery_time: parseInt(sla.shippingEstimate),
|
|
2785
|
-
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
2786
|
-
line_items: []
|
|
2787
|
-
};
|
|
2788
|
-
acc[sla.name].line_items.push(item.id);
|
|
2789
|
-
});
|
|
2790
|
-
});
|
|
2791
|
-
return Object.values(acc).map(function(s) {
|
|
2792
|
-
return _object_spread_props(_object_spread({}, s), {
|
|
2793
|
-
line_items: s.line_items.join(",")
|
|
2794
|
-
});
|
|
2795
|
-
});
|
|
2796
|
-
},
|
|
2797
|
-
shipping: function(context) {
|
|
2798
|
-
var _ref;
|
|
2799
|
-
var _context_orderForm_shippingData, _context_orderForm;
|
|
2800
|
-
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
2801
|
-
return logistics.reduce(function(total, item) {
|
|
2802
|
-
var _ref;
|
|
2803
|
-
var _item_slas;
|
|
2804
|
-
var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2805
|
-
return sla.id === item.selectedSla;
|
|
2806
|
-
});
|
|
2807
|
-
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
2808
|
-
}, 0);
|
|
2809
|
-
},
|
|
2810
|
-
shipping_tier: function(context) {
|
|
2811
|
-
var _ref;
|
|
2812
|
-
var _context_orderForm_shippingData, _context_orderForm;
|
|
2813
|
-
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
2814
|
-
var selectedSlas = logistics.map(function(item) {
|
|
2815
|
-
var _item_slas;
|
|
2816
|
-
if (!item.selectedSla) return null;
|
|
2817
|
-
return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2818
|
-
return sla.id === item.selectedSla;
|
|
2819
|
-
})) || null;
|
|
2820
|
-
}).filter(Boolean);
|
|
2821
|
-
if (selectedSlas.length === 0) return null;
|
|
2822
|
-
var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
|
|
2823
|
-
var _sla_pickupStoreInfo;
|
|
2824
|
-
var key = sla.deliveryChannel === "pickup-in-point" ? "pickup:".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) || sla.name || "") : "delivery:".concat(sla.name || "");
|
|
2825
|
-
return [
|
|
2826
|
-
key,
|
|
2827
|
-
sla
|
|
2828
|
-
];
|
|
2829
|
-
})).values());
|
|
2830
|
-
var sortedTiers = uniqueTiers.sort(function(a, b) {
|
|
2831
|
-
var _a_pickupStoreInfo, _b_pickupStoreInfo;
|
|
2832
|
-
var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2833
|
-
var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2834
|
-
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
2835
|
-
var aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a_pickupStoreInfo = a.pickupStoreInfo) === null || _a_pickupStoreInfo === void 0 ? void 0 : _a_pickupStoreInfo.friendlyName) || a.name || "" : a.name || "";
|
|
2836
|
-
var bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b_pickupStoreInfo = b.pickupStoreInfo) === null || _b_pickupStoreInfo === void 0 ? void 0 : _b_pickupStoreInfo.friendlyName) || b.name || "" : b.name || "";
|
|
2837
|
-
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
2838
|
-
});
|
|
2839
|
-
var shippingTier = sortedTiers.map(function(sla) {
|
|
2840
|
-
var _sla_pickupStoreInfo;
|
|
2841
|
-
return sla.deliveryChannel === "pickup-in-point" ? "retirada em loja".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) ? ": ".concat(sla.pickupStoreInfo.friendlyName) : "") : sla.deliveryChannel === "delivery" ? "receba em casa".concat(sla.name ? ": ".concat(sla.name) : "") : null;
|
|
2842
|
-
}).filter(Boolean).join(", ");
|
|
2843
|
-
return shippingTier || null;
|
|
2844
|
-
},
|
|
2845
|
-
transaction_id: function(context) {
|
|
2846
|
-
var _context_orderForm_orderGroup, _context_orderForm;
|
|
2847
|
-
return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
|
|
2848
|
-
},
|
|
2849
|
-
coupon: function(context) {
|
|
2850
|
-
var _context_orderForm_marketingData, _context_orderForm;
|
|
2851
|
-
return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
|
|
2852
|
-
},
|
|
2853
|
-
seller_cod_name: function(context) {
|
|
2854
|
-
return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
2855
|
-
}
|
|
2856
|
-
});
|
|
2857
2633
|
// src/params/adapters/headless/utils.ts
|
|
2858
|
-
var
|
|
2634
|
+
var getItemCategory5 = function(item) {
|
|
2859
2635
|
var keywords = [
|
|
2860
2636
|
"outlet",
|
|
2861
2637
|
"bazar",
|
|
@@ -2872,7 +2648,7 @@ var AzzasTracker = function() {
|
|
|
2872
2648
|
}
|
|
2873
2649
|
return "Cole\xE7\xE3o";
|
|
2874
2650
|
};
|
|
2875
|
-
var
|
|
2651
|
+
var getItemCategory23 = function(item) {
|
|
2876
2652
|
var _ref, _reverse_find;
|
|
2877
2653
|
var _item_categories;
|
|
2878
2654
|
var avoidList = /outlet|bazar|sale/i;
|
|
@@ -2889,7 +2665,7 @@ var AzzasTracker = function() {
|
|
|
2889
2665
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2890
2666
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2891
2667
|
return context.products.map(function(item) {
|
|
2892
|
-
var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference,
|
|
2668
|
+
var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference, _getItemCategory23, _ref3, _ref4, _item_link, _resizeVtexImage2, _ref5, _item_item_list_name;
|
|
2893
2669
|
var _item_items__sellers, _item_items__sellers1, _item_items__name, _item_items_, _item_items__name1, _item_items_1, _item_items, _item_items__images, _item_items1, _item_items__sellers2, _item_items_2, _item_items2;
|
|
2894
2670
|
var listPrice = item === null || item === void 0 ? void 0 : (_item_items__sellers = item.items[0].sellers) === null || _item_items__sellers === void 0 ? void 0 : _item_items__sellers[0].commertialOffer.ListPrice;
|
|
2895
2671
|
var price = item === null || item === void 0 ? void 0 : (_item_items__sellers1 = item.items[0].sellers) === null || _item_items__sellers1 === void 0 ? void 0 : _item_items__sellers1[0].commertialOffer.Price;
|
|
@@ -2905,8 +2681,8 @@ var AzzasTracker = function() {
|
|
|
2905
2681
|
item_variant2: (_ref2 = (_item_items_1 = item.items[0]) === null || _item_items_1 === void 0 ? void 0 : (_item_items__name1 = _item_items_1.name) === null || _item_items__name1 === void 0 ? void 0 : _item_items__name1.split(" - ")[1]) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2906
2682
|
item_ref: (_item_productReference = item.productReference) !== null && _item_productReference !== void 0 ? _item_productReference : null,
|
|
2907
2683
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
2908
|
-
item_category:
|
|
2909
|
-
item_category2: (
|
|
2684
|
+
item_category: getItemCategory5(item),
|
|
2685
|
+
item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
|
|
2910
2686
|
item_id: (_ref3 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2911
2687
|
item_sku: (_ref4 = (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items[0].itemId) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2912
2688
|
item_url: (_item_link = item.link) !== null && _item_link !== void 0 ? _item_link : null,
|
|
@@ -2944,8 +2720,8 @@ var AzzasTracker = function() {
|
|
|
2944
2720
|
}
|
|
2945
2721
|
return null;
|
|
2946
2722
|
},
|
|
2947
|
-
brand: function(context) {
|
|
2948
|
-
if (
|
|
2723
|
+
brand: function(context, config2) {
|
|
2724
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
2949
2725
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2950
2726
|
return context.products.map(function(p) {
|
|
2951
2727
|
return p.brand;
|
|
@@ -2960,7 +2736,7 @@ var AzzasTracker = function() {
|
|
|
2960
2736
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2961
2737
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2962
2738
|
return context.products.map(function(item) {
|
|
2963
|
-
var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty,
|
|
2739
|
+
var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty, _getItemCategory23, _item_isVariantOf_productGroupID, _item_sku, _resizeVtexImage2, _ref3, _item_item_list_name;
|
|
2964
2740
|
var _item_isVariantOf_hasVariant, _item_isVariantOf, _find, _item_image, _item_offers_offers_find_seller, _item_offers_offers_find, _item_offers_offers, _item_offers;
|
|
2965
2741
|
var listPrice = item.offers.highPrice;
|
|
2966
2742
|
var price = item.offers.lowPrice;
|
|
@@ -2978,8 +2754,8 @@ var AzzasTracker = function() {
|
|
|
2978
2754
|
})) === null || _find === void 0 ? void 0 : _find.value) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2979
2755
|
item_ref: null,
|
|
2980
2756
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
2981
|
-
item_category:
|
|
2982
|
-
item_category2: (
|
|
2757
|
+
item_category: getItemCategory5(item),
|
|
2758
|
+
item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
|
|
2983
2759
|
item_id: (_item_isVariantOf_productGroupID = item.isVariantOf.productGroupID) !== null && _item_isVariantOf_productGroupID !== void 0 ? _item_isVariantOf_productGroupID : null,
|
|
2984
2760
|
item_sku: (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
|
|
2985
2761
|
item_url: null,
|
|
@@ -3018,8 +2794,8 @@ var AzzasTracker = function() {
|
|
|
3018
2794
|
}
|
|
3019
2795
|
return null;
|
|
3020
2796
|
},
|
|
3021
|
-
brand: function(context) {
|
|
3022
|
-
if (
|
|
2797
|
+
brand: function(context, config2) {
|
|
2798
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
3023
2799
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3024
2800
|
return context.products.map(function(p) {
|
|
3025
2801
|
return p.brand.name;
|
|
@@ -3029,14 +2805,14 @@ var AzzasTracker = function() {
|
|
|
3029
2805
|
}
|
|
3030
2806
|
};
|
|
3031
2807
|
// src/params/adapters/headless/index.ts
|
|
3032
|
-
var headlessAdapter = _object_spread_props(_object_spread({}, metaAdapters
|
|
3033
|
-
//
|
|
3034
|
-
brand: function(context) {
|
|
2808
|
+
var headlessAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
|
|
2809
|
+
// global adapters
|
|
2810
|
+
brand: function(context, config2) {
|
|
3035
2811
|
if (context.zone === "PDP") {
|
|
3036
|
-
return HeadlessPdpZone.brand(context);
|
|
2812
|
+
return HeadlessPdpZone.brand(context, config2);
|
|
3037
2813
|
}
|
|
3038
2814
|
if (context.zone === "PDC") {
|
|
3039
|
-
return HeadlessPdcZone.brand(context);
|
|
2815
|
+
return HeadlessPdcZone.brand(context, config2);
|
|
3040
2816
|
}
|
|
3041
2817
|
return null;
|
|
3042
2818
|
},
|
|
@@ -3122,6 +2898,235 @@ var AzzasTracker = function() {
|
|
|
3122
2898
|
return (_context_zipcode = context.zipcode) !== null && _context_zipcode !== void 0 ? _context_zipcode : null;
|
|
3123
2899
|
}
|
|
3124
2900
|
});
|
|
2901
|
+
// src/params/adapters/orderForm/utils.ts
|
|
2902
|
+
var getItemCategory6 = function(item) {
|
|
2903
|
+
var _text_match;
|
|
2904
|
+
var categories = item === null || item === void 0 ? void 0 : item.productCategories;
|
|
2905
|
+
if (!categories) return "Cole\xE7\xE3o";
|
|
2906
|
+
var text = Object.values(categories).join(" ");
|
|
2907
|
+
var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
|
|
2908
|
+
return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
|
|
2909
|
+
};
|
|
2910
|
+
var getItemCategory24 = function(item) {
|
|
2911
|
+
var _ref, _validHierarchy_;
|
|
2912
|
+
var AVOID_CATEGORIES = /outlet|bazar|sale/i;
|
|
2913
|
+
var categories = Object.values((_ref = item === null || item === void 0 ? void 0 : item.productCategories) !== null && _ref !== void 0 ? _ref : {});
|
|
2914
|
+
var validHierarchy = categories.map(function(c) {
|
|
2915
|
+
return c.trim();
|
|
2916
|
+
}).filter(function(c) {
|
|
2917
|
+
return c && !AVOID_CATEGORIES.test(c);
|
|
2918
|
+
});
|
|
2919
|
+
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
2920
|
+
return capitalize(deepest);
|
|
2921
|
+
};
|
|
2922
|
+
var getOrderFormItems = function(orderForm) {
|
|
2923
|
+
var idSelected = orderForm === null || orderForm === void 0 ? void 0 : orderForm.selected;
|
|
2924
|
+
return idSelected ? orderForm.items.filter(function(item) {
|
|
2925
|
+
return item.id === idSelected;
|
|
2926
|
+
}) : orderForm.items;
|
|
2927
|
+
};
|
|
2928
|
+
// src/params/adapters/orderForm/index.ts
|
|
2929
|
+
var orderFormAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
|
|
2930
|
+
items: function(context) {
|
|
2931
|
+
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2932
|
+
if ((context === null || context === void 0 ? void 0 : context.orderForm) && (context === null || context === void 0 ? void 0 : context.orderForm.items)) {
|
|
2933
|
+
return getOrderFormItems(context.orderForm).map(function(item, index) {
|
|
2934
|
+
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _getItemCategory6, _getItemCategory24, _ref7, _ref8, _item_detailUrl, _resizeVtexImage2, _ref9, _ref10;
|
|
2935
|
+
var _context_orderForm, _item_additionalInfo, _item_skuName_split__split_pop, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _context_orderForm1;
|
|
2936
|
+
return {
|
|
2937
|
+
quantity: (_ref = item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1,
|
|
2938
|
+
index: (_ref1 = (_ref2 = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.index) !== null && _ref2 !== void 0 ? _ref2 : index) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2939
|
+
item_brand: (_ref3 = (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2940
|
+
item_name: (_ref4 = item === null || item === void 0 ? void 0 : item.name.replace(item === null || item === void 0 ? void 0 : item.skuName, "").trim()) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2941
|
+
price: (item === null || item === void 0 ? void 0 : item.price) / 100,
|
|
2942
|
+
discount: ((item === null || item === void 0 ? void 0 : item.listPrice) - (item === null || item === void 0 ? void 0 : item.sellingPrice)) / 100,
|
|
2943
|
+
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,
|
|
2944
|
+
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,
|
|
2945
|
+
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
2946
|
+
item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
2947
|
+
item_category: (_getItemCategory6 = getItemCategory6(item)) !== null && _getItemCategory6 !== void 0 ? _getItemCategory6 : null,
|
|
2948
|
+
item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
|
|
2949
|
+
item_id: (_ref7 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
2950
|
+
item_sku: (_ref8 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref8 !== void 0 ? _ref8 : null,
|
|
2951
|
+
item_url: (_item_detailUrl = item.detailUrl) !== null && _item_detailUrl !== void 0 ? _item_detailUrl : null,
|
|
2952
|
+
image_url: (_resizeVtexImage2 = resizeVtexImage2(item.imageUrl)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
|
|
2953
|
+
seller_id: (_ref9 = item === null || item === void 0 ? void 0 : item.seller) !== null && _ref9 !== void 0 ? _ref9 : null,
|
|
2954
|
+
item_list_name: (_ref10 = context === null || context === void 0 ? void 0 : (_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.item_list_name) !== null && _ref10 !== void 0 ? _ref10 : null
|
|
2955
|
+
};
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
return null;
|
|
2959
|
+
},
|
|
2960
|
+
brand: function(context, config2) {
|
|
2961
|
+
var _context_orderForm;
|
|
2962
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
2963
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2964
|
+
var brands = getOrderFormItems(context.orderForm).map(function(item) {
|
|
2965
|
+
return item.additionalInfo.brandName;
|
|
2966
|
+
});
|
|
2967
|
+
return normalizeBrand2(brands);
|
|
2968
|
+
},
|
|
2969
|
+
line_items: function(context) {
|
|
2970
|
+
var _context_orderForm;
|
|
2971
|
+
if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
|
|
2972
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2973
|
+
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2974
|
+
return item === null || item === void 0 ? void 0 : item.productId;
|
|
2975
|
+
}).filter(function(id) {
|
|
2976
|
+
return Boolean(id);
|
|
2977
|
+
});
|
|
2978
|
+
},
|
|
2979
|
+
value: function(context) {
|
|
2980
|
+
var _context_orderForm;
|
|
2981
|
+
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
2982
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2983
|
+
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2984
|
+
return (item === null || item === void 0 ? void 0 : item.price) / 100 * item.quantity;
|
|
2985
|
+
}).filter(function(price) {
|
|
2986
|
+
return price !== void 0;
|
|
2987
|
+
}).reduce(function(sum, price) {
|
|
2988
|
+
return sum + price;
|
|
2989
|
+
}, 0);
|
|
2990
|
+
},
|
|
2991
|
+
payment_type: getPaymentType,
|
|
2992
|
+
total_discount: function(context) {
|
|
2993
|
+
var _context_orderForm, _context_orderForm1;
|
|
2994
|
+
if (context === null || context === void 0 ? void 0 : context.total_discount) return context.total_discount;
|
|
2995
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2996
|
+
var totalsList = ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totalizers) || [];
|
|
2997
|
+
var totalDiscount = getOrderFormItems(context.orderForm).reduce(function(acc, item) {
|
|
2998
|
+
var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
2999
|
+
return acc + unitDiscount * item.quantity;
|
|
3000
|
+
}, 0);
|
|
3001
|
+
var discounts = totalsList.find(function(t) {
|
|
3002
|
+
return t.id === "Discounts";
|
|
3003
|
+
});
|
|
3004
|
+
return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
3005
|
+
},
|
|
3006
|
+
subtotal: function(context) {
|
|
3007
|
+
var _context_orderForm, _context_orderForm1;
|
|
3008
|
+
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) || [];
|
|
3009
|
+
var subtotal = totalsList.filter(function(t) {
|
|
3010
|
+
return t.id === "Items";
|
|
3011
|
+
}).reduce(function(acc, t) {
|
|
3012
|
+
return acc + (t.value || 0);
|
|
3013
|
+
}, 0) / 100 || 0;
|
|
3014
|
+
return subtotal;
|
|
3015
|
+
},
|
|
3016
|
+
coupon_message: function(context) {
|
|
3017
|
+
var _context_orderForm;
|
|
3018
|
+
if (context.couponMessage) return context.couponMessage;
|
|
3019
|
+
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
3020
|
+
if (messages.length === 0) return null;
|
|
3021
|
+
var couponMessages = messages.filter(function(msg) {
|
|
3022
|
+
return msg.text.toLowerCase().includes("cupom");
|
|
3023
|
+
});
|
|
3024
|
+
if (couponMessages.length === 0) return null;
|
|
3025
|
+
return couponMessages.map(function(msg) {
|
|
3026
|
+
return msg.text;
|
|
3027
|
+
}).join(" | ");
|
|
3028
|
+
},
|
|
3029
|
+
zipcode: function(context) {
|
|
3030
|
+
var _context_zipcode;
|
|
3031
|
+
return (_context_zipcode = context.zipcode) !== null && _context_zipcode !== void 0 ? _context_zipcode : null;
|
|
3032
|
+
},
|
|
3033
|
+
flag_pickup: function(context) {
|
|
3034
|
+
var _orderForm_shippingData;
|
|
3035
|
+
var orderForm = context.orderForm;
|
|
3036
|
+
if (!orderForm) return null;
|
|
3037
|
+
var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
|
|
3038
|
+
var hasPickup = logisticsInfo.some(function(info) {
|
|
3039
|
+
var _info_slas;
|
|
3040
|
+
return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
|
|
3041
|
+
return sla.deliveryChannel === "pickup-in-point";
|
|
3042
|
+
});
|
|
3043
|
+
});
|
|
3044
|
+
return hasPickup;
|
|
3045
|
+
},
|
|
3046
|
+
shippings: function(context) {
|
|
3047
|
+
if (!context.orderForm) return null;
|
|
3048
|
+
var _context_orderForm = context.orderForm, items = _context_orderForm.items, shippingData = _context_orderForm.shippingData;
|
|
3049
|
+
var acc = {};
|
|
3050
|
+
shippingData.logisticsInfo.forEach(function(param) {
|
|
3051
|
+
var itemIndex = param.itemIndex, slas = param.slas;
|
|
3052
|
+
var item = items[itemIndex];
|
|
3053
|
+
if (!item) return;
|
|
3054
|
+
slas.forEach(function(sla) {
|
|
3055
|
+
if (!acc[sla.name]) acc[sla.name] = {
|
|
3056
|
+
shipping_tier: sla.name,
|
|
3057
|
+
delivery_time: parseInt(sla.shippingEstimate),
|
|
3058
|
+
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
3059
|
+
line_items: []
|
|
3060
|
+
};
|
|
3061
|
+
acc[sla.name].line_items.push(item.id);
|
|
3062
|
+
});
|
|
3063
|
+
});
|
|
3064
|
+
return Object.values(acc).map(function(s) {
|
|
3065
|
+
return _object_spread_props(_object_spread({}, s), {
|
|
3066
|
+
line_items: s.line_items.join(",")
|
|
3067
|
+
});
|
|
3068
|
+
});
|
|
3069
|
+
},
|
|
3070
|
+
shipping: function(context) {
|
|
3071
|
+
var _ref;
|
|
3072
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
3073
|
+
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
3074
|
+
return logistics.reduce(function(total, item) {
|
|
3075
|
+
var _ref;
|
|
3076
|
+
var _item_slas;
|
|
3077
|
+
var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
3078
|
+
return sla.id === item.selectedSla;
|
|
3079
|
+
});
|
|
3080
|
+
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
3081
|
+
}, 0);
|
|
3082
|
+
},
|
|
3083
|
+
shipping_tier: function(context) {
|
|
3084
|
+
var _ref;
|
|
3085
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
3086
|
+
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
3087
|
+
var selectedSlas = logistics.map(function(item) {
|
|
3088
|
+
var _item_slas;
|
|
3089
|
+
if (!item.selectedSla) return null;
|
|
3090
|
+
return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
3091
|
+
return sla.id === item.selectedSla;
|
|
3092
|
+
})) || null;
|
|
3093
|
+
}).filter(Boolean);
|
|
3094
|
+
if (selectedSlas.length === 0) return null;
|
|
3095
|
+
var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
|
|
3096
|
+
var _sla_pickupStoreInfo;
|
|
3097
|
+
var key = sla.deliveryChannel === "pickup-in-point" ? "pickup:".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) || sla.name || "") : "delivery:".concat(sla.name || "");
|
|
3098
|
+
return [
|
|
3099
|
+
key,
|
|
3100
|
+
sla
|
|
3101
|
+
];
|
|
3102
|
+
})).values());
|
|
3103
|
+
var sortedTiers = uniqueTiers.sort(function(a, b) {
|
|
3104
|
+
var _a_pickupStoreInfo, _b_pickupStoreInfo;
|
|
3105
|
+
var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
3106
|
+
var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
3107
|
+
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
3108
|
+
var aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a_pickupStoreInfo = a.pickupStoreInfo) === null || _a_pickupStoreInfo === void 0 ? void 0 : _a_pickupStoreInfo.friendlyName) || a.name || "" : a.name || "";
|
|
3109
|
+
var bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b_pickupStoreInfo = b.pickupStoreInfo) === null || _b_pickupStoreInfo === void 0 ? void 0 : _b_pickupStoreInfo.friendlyName) || b.name || "" : b.name || "";
|
|
3110
|
+
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
3111
|
+
});
|
|
3112
|
+
var shippingTier = sortedTiers.map(function(sla) {
|
|
3113
|
+
var _sla_pickupStoreInfo;
|
|
3114
|
+
return sla.deliveryChannel === "pickup-in-point" ? "retirada em loja".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) ? ": ".concat(sla.pickupStoreInfo.friendlyName) : "") : sla.deliveryChannel === "delivery" ? "receba em casa".concat(sla.name ? ": ".concat(sla.name) : "") : null;
|
|
3115
|
+
}).filter(Boolean).join(", ");
|
|
3116
|
+
return shippingTier || null;
|
|
3117
|
+
},
|
|
3118
|
+
transaction_id: function(context) {
|
|
3119
|
+
var _context_orderForm_orderGroup, _context_orderForm;
|
|
3120
|
+
return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
|
|
3121
|
+
},
|
|
3122
|
+
coupon: function(context) {
|
|
3123
|
+
var _context_orderForm_marketingData, _context_orderForm;
|
|
3124
|
+
return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
|
|
3125
|
+
},
|
|
3126
|
+
seller_cod_name: function(context) {
|
|
3127
|
+
return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
3128
|
+
}
|
|
3129
|
+
});
|
|
3125
3130
|
// src/formatter.ts
|
|
3126
3131
|
var adapters = {
|
|
3127
3132
|
DECO: decoAdapter,
|
|
@@ -3129,6 +3134,11 @@ var AzzasTracker = function() {
|
|
|
3129
3134
|
PICKUP: pickupAdapter,
|
|
3130
3135
|
ORDERFORM: orderFormAdapter
|
|
3131
3136
|
};
|
|
3137
|
+
// src/index.ts
|
|
3138
|
+
var config = {
|
|
3139
|
+
brand: "",
|
|
3140
|
+
currency: "BRL"
|
|
3141
|
+
};
|
|
3132
3142
|
var src_default = {
|
|
3133
3143
|
trackWebEvent: trackWebEvent,
|
|
3134
3144
|
EVENTS: EVENTS
|