@azzas/azzas-tracker-web 2.0.0-preview.16 → 2.0.0-preview.18
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 +34 -25
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.global.js +34 -25
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +34 -25
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +48 -30
- package/package.json +1 -1
package/dist/mod.global.js
CHANGED
|
@@ -1814,6 +1814,10 @@ var AzzasTracker = (() => {
|
|
|
1814
1814
|
};
|
|
1815
1815
|
|
|
1816
1816
|
// src/params/adapters/orderForm/utils.ts
|
|
1817
|
+
var getOrderFormItems = (orderForm) => {
|
|
1818
|
+
const idSelected = orderForm == null ? void 0 : orderForm.selected;
|
|
1819
|
+
return idSelected ? orderForm.items.filter((item) => item.id === idSelected) : orderForm.items;
|
|
1820
|
+
};
|
|
1817
1821
|
var getItemCategory6 = (item) => {
|
|
1818
1822
|
var _a;
|
|
1819
1823
|
const categories = item == null ? void 0 : item.productCategories;
|
|
@@ -1838,9 +1842,20 @@ var AzzasTracker = (() => {
|
|
|
1838
1842
|
const selectedSla = (_c = info == null ? void 0 : info.slas) == null ? void 0 : _c.find((sla) => sla.id === info.selectedSla);
|
|
1839
1843
|
return ((_d = selectedSla == null ? void 0 : selectedSla.pickupStoreInfo) == null ? void 0 : _d.friendlyName) ? `retirada em loja: ${selectedSla.pickupStoreInfo.friendlyName}` : (selectedSla == null ? void 0 : selectedSla.name) ? `Receba em casa: ${selectedSla.name}` : null;
|
|
1840
1844
|
}
|
|
1841
|
-
var
|
|
1842
|
-
|
|
1843
|
-
|
|
1845
|
+
var getPaymentType2 = (context) => {
|
|
1846
|
+
var _a, _b, _c;
|
|
1847
|
+
if (context.payment_type) return context.payment_type;
|
|
1848
|
+
if (!context.orderForm) return null;
|
|
1849
|
+
const payments = ((_a = context.orderForm.paymentData) == null ? void 0 : _a.payments) || [];
|
|
1850
|
+
const systems = ((_b = context.orderForm.paymentData) == null ? void 0 : _b.paymentSystems) || [];
|
|
1851
|
+
if (!payments.length || !systems.length) return null;
|
|
1852
|
+
const selectedPayment = payments.find((p) => p == null ? void 0 : p.paymentSystem) || payments[0];
|
|
1853
|
+
const id = String((selectedPayment == null ? void 0 : selectedPayment.paymentSystem) || "").trim();
|
|
1854
|
+
if (!id) return null;
|
|
1855
|
+
const system = systems.find((s) => String(s.id) === id);
|
|
1856
|
+
const name = ((_c = system == null ? void 0 : system.name) == null ? void 0 : _c.toLowerCase()) || "";
|
|
1857
|
+
const match = paymentTypeMap.find(([key]) => name.includes(key));
|
|
1858
|
+
return match ? match[1] : null;
|
|
1844
1859
|
};
|
|
1845
1860
|
|
|
1846
1861
|
// src/params/adapters/orderForm/index.ts
|
|
@@ -1856,7 +1871,7 @@ var AzzasTracker = (() => {
|
|
|
1856
1871
|
index: (_c = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.index) != null ? _c : index + 1,
|
|
1857
1872
|
item_brand: (_e = (_d = item.additionalInfo) == null ? void 0 : _d.brandName) != null ? _e : null,
|
|
1858
1873
|
item_name: (_f = item == null ? void 0 : item.name.replace(item == null ? void 0 : item.skuName, "").trim()) != null ? _f : null,
|
|
1859
|
-
price: (item == null ? void 0 : item.
|
|
1874
|
+
price: (item == null ? void 0 : item.sellingPrice) / 100,
|
|
1860
1875
|
discount: ((item == null ? void 0 : item.listPrice) - (item == null ? void 0 : item.sellingPrice)) / 100,
|
|
1861
1876
|
item_variant: (_j = (_i = (_h = (_g = item == null ? void 0 : item.skuName) == null ? void 0 : _g.split(" - ")[0]) == null ? void 0 : _h.split("_").pop()) == null ? void 0 : _i.trim()) != null ? _j : null,
|
|
1862
1877
|
item_variant2: (_m = (_l = (_k = item == null ? void 0 : item.skuName) == null ? void 0 : _k.split(" - ")[1]) == null ? void 0 : _l.trim()) != null ? _m : null,
|
|
@@ -1893,20 +1908,16 @@ var AzzasTracker = (() => {
|
|
|
1893
1908
|
var _a;
|
|
1894
1909
|
if (context == null ? void 0 : context.value) return context.value;
|
|
1895
1910
|
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1896
|
-
return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.
|
|
1911
|
+
return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.sellingPrice) / 100 * item.quantity).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
|
|
1897
1912
|
},
|
|
1898
|
-
payment_type:
|
|
1913
|
+
payment_type: getPaymentType2,
|
|
1899
1914
|
total_discount: (context) => {
|
|
1900
|
-
var _a, _b;
|
|
1915
|
+
var _a, _b, _c;
|
|
1901
1916
|
if (context == null ? void 0 : context.total_discount) return context.total_discount;
|
|
1902
1917
|
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1903
|
-
const
|
|
1904
|
-
const
|
|
1905
|
-
|
|
1906
|
-
return acc + unitDiscount * item.quantity;
|
|
1907
|
-
}, 0);
|
|
1908
|
-
const discounts = totalsList.find((t) => t.id === "Discounts");
|
|
1909
|
-
return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
1918
|
+
const totalizers = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.totalizers;
|
|
1919
|
+
const productDiscount = ((_c = totalizers.find((t) => t.id === "Discounts")) == null ? void 0 : _c.value) || 0;
|
|
1920
|
+
return Math.abs(productDiscount) / 100 || null;
|
|
1910
1921
|
},
|
|
1911
1922
|
subtotal: (context) => {
|
|
1912
1923
|
var _a, _b;
|
|
@@ -1914,17 +1925,6 @@ var AzzasTracker = (() => {
|
|
|
1914
1925
|
const subtotal = totalsList.filter((t) => t.id === "Items").reduce((acc, t) => acc + (t.value || 0), 0) / 100 || 0;
|
|
1915
1926
|
return subtotal;
|
|
1916
1927
|
},
|
|
1917
|
-
coupon_message: (context) => {
|
|
1918
|
-
var _a;
|
|
1919
|
-
if (context.couponMessage) return context.couponMessage;
|
|
1920
|
-
const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
|
|
1921
|
-
if (messages.length === 0) return null;
|
|
1922
|
-
const couponMessages = messages.filter(
|
|
1923
|
-
(msg) => msg.text.toLowerCase().includes("cupom")
|
|
1924
|
-
);
|
|
1925
|
-
if (couponMessages.length === 0) return null;
|
|
1926
|
-
return couponMessages.map((msg) => msg.text).join(" | ");
|
|
1927
|
-
},
|
|
1928
1928
|
zipcode: (context) => {
|
|
1929
1929
|
var _a;
|
|
1930
1930
|
return (_a = context.meta.zipcode) != null ? _a : null;
|
|
@@ -2007,6 +2007,15 @@ var AzzasTracker = (() => {
|
|
|
2007
2007
|
var _a, _b;
|
|
2008
2008
|
return ((_b = (_a = context.orderForm) == null ? void 0 : _a.orderGroup) == null ? void 0 : _b.toString()) || null;
|
|
2009
2009
|
},
|
|
2010
|
+
coupon_message: (context) => {
|
|
2011
|
+
var _a;
|
|
2012
|
+
if (context.couponMessage) return context.couponMessage;
|
|
2013
|
+
const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
|
|
2014
|
+
if (messages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
|
|
2015
|
+
const couponMessages = messages.filter((msg) => msg.text.toLowerCase().includes("cupom"));
|
|
2016
|
+
if (couponMessages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
|
|
2017
|
+
return couponMessages.map((msg) => msg.text).join(" | ");
|
|
2018
|
+
},
|
|
2010
2019
|
coupon: (context) => {
|
|
2011
2020
|
var _a, _b;
|
|
2012
2021
|
return context.appliedCoupon || ((_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.marketingData) == null ? void 0 : _b.coupon) || null;
|