@azzas/azzas-tracker-web 1.0.84 → 1.0.86
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 +58 -34
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.global.js +58 -34
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +58 -34
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +82 -58
- package/package.json +1 -1
package/dist/mod.vtex.global.js
CHANGED
|
@@ -538,10 +538,6 @@ var AzzasTracker = function() {
|
|
|
538
538
|
};
|
|
539
539
|
var getItemCategory = function getItemCategory(item) {
|
|
540
540
|
var strategies = [
|
|
541
|
-
function() {
|
|
542
|
-
var _item_productCategories;
|
|
543
|
-
return (item === null || item === void 0 ? void 0 : (_item_productCategories = item.productCategories) === null || _item_productCategories === void 0 ? void 0 : _item_productCategories["39"]) === "BAZAR" ? "Sale" : "Cole\xE7\xE3o";
|
|
544
|
-
},
|
|
545
541
|
function() {
|
|
546
542
|
return item === null || item === void 0 ? void 0 : item.item_category;
|
|
547
543
|
},
|
|
@@ -551,6 +547,10 @@ var AzzasTracker = function() {
|
|
|
551
547
|
function() {
|
|
552
548
|
return item === null || item === void 0 ? void 0 : item.categories[0];
|
|
553
549
|
},
|
|
550
|
+
function() {
|
|
551
|
+
var _item_productCategories;
|
|
552
|
+
return (item === null || item === void 0 ? void 0 : (_item_productCategories = item.productCategories) === null || _item_productCategories === void 0 ? void 0 : _item_productCategories["39"]) === "BAZAR" ? "Sale" : "Cole\xE7\xE3o";
|
|
553
|
+
},
|
|
554
554
|
function() {
|
|
555
555
|
var _item_itemOffered_breadcrumbList, _item_itemOffered;
|
|
556
556
|
var breadcrumb = item === null || item === void 0 ? void 0 : (_item_itemOffered = item.itemOffered) === null || _item_itemOffered === void 0 ? void 0 : (_item_itemOffered_breadcrumbList = _item_itemOffered.breadcrumbList) === null || _item_itemOffered_breadcrumbList === void 0 ? void 0 : _item_itemOffered_breadcrumbList.itemListElement;
|
|
@@ -570,7 +570,7 @@ var AzzasTracker = function() {
|
|
|
570
570
|
var getValue = _step.value;
|
|
571
571
|
var value = getValue();
|
|
572
572
|
if (value !== null && value !== void 0) {
|
|
573
|
-
return value;
|
|
573
|
+
return value.toLowerCase();
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
576
|
} catch (err) {
|
|
@@ -707,59 +707,6 @@ var AzzasTracker = function() {
|
|
|
707
707
|
return null;
|
|
708
708
|
}
|
|
709
709
|
};
|
|
710
|
-
var itemsFromOrderForm = // src/params/resolvers/items/fromOrderForm.ts
|
|
711
|
-
function itemsFromOrderForm(context) {
|
|
712
|
-
return _async_to_generator(function() {
|
|
713
|
-
var _context_orderForm, items;
|
|
714
|
-
return _ts_generator(this, function(_state) {
|
|
715
|
-
switch(_state.label){
|
|
716
|
-
case 0:
|
|
717
|
-
items = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items) || [];
|
|
718
|
-
if (!items.length) return [
|
|
719
|
-
2,
|
|
720
|
-
[]
|
|
721
|
-
];
|
|
722
|
-
return [
|
|
723
|
-
4,
|
|
724
|
-
Promise.all(items.map(function(item) {
|
|
725
|
-
return _async_to_generator(function() {
|
|
726
|
-
var _item_additionalInfo, _item_additionalInfo1, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _tmp;
|
|
727
|
-
return _ts_generator(this, function(_state) {
|
|
728
|
-
switch(_state.label){
|
|
729
|
-
case 0:
|
|
730
|
-
_tmp = {
|
|
731
|
-
item_id: item.productId,
|
|
732
|
-
item_category2: getItemCategory2(item),
|
|
733
|
-
item_category4: getItemCategory4(item),
|
|
734
|
-
item_shipping_tier: getItemShippingTier(context.orderForm, item),
|
|
735
|
-
price: parseFloat(((item === null || item === void 0 ? void 0 : item.price) / 100).toFixed(2)) || 0,
|
|
736
|
-
quantity: item.quantity || 1,
|
|
737
|
-
item_ref: item.refId || null,
|
|
738
|
-
item_brand: normalizeBrand((_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || ((_item_additionalInfo1 = item.additionalInfo) === null || _item_additionalInfo1 === void 0 ? void 0 : _item_additionalInfo1.brandName) || null
|
|
739
|
-
};
|
|
740
|
-
return [
|
|
741
|
-
4,
|
|
742
|
-
getItemSku(item)
|
|
743
|
-
];
|
|
744
|
-
case 1:
|
|
745
|
-
return [
|
|
746
|
-
2,
|
|
747
|
-
(_tmp.item_sku = _state.sent() || null, _tmp.item_name = (item === null || item === void 0 ? void 0 : item.name.replace(item === null || item === void 0 ? void 0 : item.skuName, "").trim()) || item.name || null, _tmp.item_category = getItemCategory(item) || null, _tmp.item_variant = (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_.trim()) || "", _tmp.item_variant2 = (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()) || "", _tmp.item_url = "https://www.farmrio.com.br".concat(item.detailUrl) || null, _tmp.discount = getDiscount(item), _tmp.image_url = resizeVtexImage(item === null || item === void 0 ? void 0 : item.image) || resizeVtexImage(item === null || item === void 0 ? void 0 : item.imageUrl) || null, _tmp)
|
|
748
|
-
];
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
})();
|
|
752
|
-
}))
|
|
753
|
-
];
|
|
754
|
-
case 1:
|
|
755
|
-
return [
|
|
756
|
-
2,
|
|
757
|
-
_state.sent()
|
|
758
|
-
];
|
|
759
|
-
}
|
|
760
|
-
});
|
|
761
|
-
})();
|
|
762
|
-
};
|
|
763
710
|
var getStorage = function getStorage() {
|
|
764
711
|
try {
|
|
765
712
|
if (typeof window === "undefined" || !window.localStorage) return null;
|
|
@@ -846,6 +793,16 @@ var AzzasTracker = function() {
|
|
|
846
793
|
storage.setItem(CART_LIST_HISTORY_KEY, JSON.stringify(history));
|
|
847
794
|
} catch (unused) {}
|
|
848
795
|
};
|
|
796
|
+
var getLatestItemListNameById = function getLatestItemListNameById(history) {
|
|
797
|
+
var byId = /* @__PURE__ */ new Map();
|
|
798
|
+
for(var index = history.length - 1; index >= 0; index -= 1){
|
|
799
|
+
var entry = history[index];
|
|
800
|
+
if (!byId.has(entry.item_id)) {
|
|
801
|
+
byId.set(entry.item_id, entry.item_list_name);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
return byId;
|
|
805
|
+
};
|
|
849
806
|
var saveSelectedItem = function saveSelectedItem(productId, listName) {
|
|
850
807
|
if (productId == null || !listName) return;
|
|
851
808
|
var payload = {
|
|
@@ -896,6 +853,19 @@ var AzzasTracker = function() {
|
|
|
896
853
|
});
|
|
897
854
|
writeCartHistory(history);
|
|
898
855
|
};
|
|
856
|
+
var getCartHistoryItemListNameMap = function getCartHistoryItemListNameMap() {
|
|
857
|
+
var history = readCartHistory();
|
|
858
|
+
if (!history.length) return null;
|
|
859
|
+
return getLatestItemListNameById(history);
|
|
860
|
+
};
|
|
861
|
+
var resolveItemListNameFromCartHistory = function resolveItemListNameFromCartHistory(item) {
|
|
862
|
+
var cartHistoryMap = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
|
|
863
|
+
var itemId = resolveIdFromUnknownItem(item);
|
|
864
|
+
var map = cartHistoryMap !== null && cartHistoryMap !== void 0 ? cartHistoryMap : getCartHistoryItemListNameMap();
|
|
865
|
+
if (!itemId) return void 0;
|
|
866
|
+
var resolved = map === null || map === void 0 ? void 0 : map.get(itemId);
|
|
867
|
+
return resolved;
|
|
868
|
+
};
|
|
899
869
|
var pickSelectedItemFromResolvedItems = function pickSelectedItemFromResolvedItems(items, source) {
|
|
900
870
|
if (!Array.isArray(items) || items.length === 0) return null;
|
|
901
871
|
if (typeof (source === null || source === void 0 ? void 0 : source.index) === "number") {
|
|
@@ -915,6 +885,60 @@ var AzzasTracker = function() {
|
|
|
915
885
|
var listName = (_ref = (_ref1 = (_ref2 = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.item_list_name) !== null && _ref2 !== void 0 ? _ref2 : source === null || source === void 0 ? void 0 : source.itemListName) !== null && _ref1 !== void 0 ? _ref1 : source === null || source === void 0 ? void 0 : source.item_list_name) !== null && _ref !== void 0 ? _ref : null;
|
|
916
886
|
saveSelectedItem(productId, listName);
|
|
917
887
|
};
|
|
888
|
+
var itemsFromOrderForm = // src/params/resolvers/items/fromOrderForm.ts
|
|
889
|
+
function itemsFromOrderForm(context) {
|
|
890
|
+
return _async_to_generator(function() {
|
|
891
|
+
var _context_orderForm, items, cartHistoryMap;
|
|
892
|
+
return _ts_generator(this, function(_state) {
|
|
893
|
+
switch(_state.label){
|
|
894
|
+
case 0:
|
|
895
|
+
items = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items) || [];
|
|
896
|
+
cartHistoryMap = getCartHistoryItemListNameMap();
|
|
897
|
+
if (!items.length) return [
|
|
898
|
+
2,
|
|
899
|
+
[]
|
|
900
|
+
];
|
|
901
|
+
return [
|
|
902
|
+
4,
|
|
903
|
+
Promise.all(items.map(function(item) {
|
|
904
|
+
return _async_to_generator(function() {
|
|
905
|
+
var _resolveItemListNameFromCartHistory, _item_additionalInfo, _item_additionalInfo1, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _tmp;
|
|
906
|
+
return _ts_generator(this, function(_state) {
|
|
907
|
+
switch(_state.label){
|
|
908
|
+
case 0:
|
|
909
|
+
_tmp = {
|
|
910
|
+
item_id: item.productId,
|
|
911
|
+
item_category2: getItemCategory2(item),
|
|
912
|
+
item_category4: getItemCategory4(item),
|
|
913
|
+
item_shipping_tier: getItemShippingTier(context.orderForm, item),
|
|
914
|
+
price: parseFloat(((item === null || item === void 0 ? void 0 : item.price) / 100).toFixed(2)) || 0,
|
|
915
|
+
quantity: item.quantity || 1,
|
|
916
|
+
item_ref: item.refId || null,
|
|
917
|
+
item_brand: normalizeBrand((_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || ((_item_additionalInfo1 = item.additionalInfo) === null || _item_additionalInfo1 === void 0 ? void 0 : _item_additionalInfo1.brandName) || null
|
|
918
|
+
};
|
|
919
|
+
return [
|
|
920
|
+
4,
|
|
921
|
+
getItemSku(item)
|
|
922
|
+
];
|
|
923
|
+
case 1:
|
|
924
|
+
return [
|
|
925
|
+
2,
|
|
926
|
+
(_tmp.item_sku = _state.sent() || null, _tmp.item_name = (item === null || item === void 0 ? void 0 : item.name.replace(item === null || item === void 0 ? void 0 : item.skuName, "").trim()) || item.name || null, _tmp.item_category = getItemCategory(item) || null, _tmp.item_variant = (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_.trim()) || "", _tmp.item_variant2 = (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()) || "", _tmp.item_url = "https://www.farmrio.com.br".concat(item.detailUrl) || null, _tmp.discount = getDiscount(item), _tmp.image_url = resizeVtexImage(item === null || item === void 0 ? void 0 : item.image) || resizeVtexImage(item === null || item === void 0 ? void 0 : item.imageUrl) || null, _tmp.item_list_name = (_resolveItemListNameFromCartHistory = resolveItemListNameFromCartHistory(item, cartHistoryMap)) !== null && _resolveItemListNameFromCartHistory !== void 0 ? _resolveItemListNameFromCartHistory : null, _tmp)
|
|
927
|
+
];
|
|
928
|
+
}
|
|
929
|
+
});
|
|
930
|
+
})();
|
|
931
|
+
}))
|
|
932
|
+
];
|
|
933
|
+
case 1:
|
|
934
|
+
return [
|
|
935
|
+
2,
|
|
936
|
+
_state.sent()
|
|
937
|
+
];
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
})();
|
|
941
|
+
};
|
|
918
942
|
var itemsFromItem = // src/params/resolvers/items/fromItem.ts
|
|
919
943
|
function itemsFromItem(context, event) {
|
|
920
944
|
return _async_to_generator(function() {
|