@azzas/azzas-tracker-web 2.0.0-preview.16 → 2.0.0-preview.17

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 CHANGED
@@ -1814,6 +1814,10 @@ var pickupAdapter = {
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 @@ function getItemShippingTier2(orderForm, item) {
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 getOrderFormItems = (orderForm) => {
1842
- const idSelected = orderForm == null ? void 0 : orderForm.selected;
1843
- return idSelected ? orderForm.items.filter((item) => item.id === idSelected) : orderForm.items;
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
@@ -1895,7 +1910,7 @@ var orderFormAdapter = {
1895
1910
  if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1896
1911
  return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.price) / 100 * item.quantity).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
1897
1912
  },
1898
- payment_type: getPaymentType,
1913
+ payment_type: getPaymentType2,
1899
1914
  total_discount: (context) => {
1900
1915
  var _a, _b;
1901
1916
  if (context == null ? void 0 : context.total_discount) return context.total_discount;
@@ -1914,17 +1929,6 @@ var orderFormAdapter = {
1914
1929
  const subtotal = totalsList.filter((t) => t.id === "Items").reduce((acc, t) => acc + (t.value || 0), 0) / 100 || 0;
1915
1930
  return subtotal;
1916
1931
  },
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
1932
  zipcode: (context) => {
1929
1933
  var _a;
1930
1934
  return (_a = context.meta.zipcode) != null ? _a : null;
@@ -2007,6 +2011,15 @@ var orderFormAdapter = {
2007
2011
  var _a, _b;
2008
2012
  return ((_b = (_a = context.orderForm) == null ? void 0 : _a.orderGroup) == null ? void 0 : _b.toString()) || null;
2009
2013
  },
2014
+ coupon_message: (context) => {
2015
+ var _a;
2016
+ if (context.couponMessage) return context.couponMessage;
2017
+ const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
2018
+ if (messages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
2019
+ const couponMessages = messages.filter((msg) => msg.text.toLowerCase().includes("cupom"));
2020
+ if (couponMessages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
2021
+ return couponMessages.map((msg) => msg.text).join(" | ");
2022
+ },
2010
2023
  coupon: (context) => {
2011
2024
  var _a, _b;
2012
2025
  return context.appliedCoupon || ((_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.marketingData) == null ? void 0 : _b.coupon) || null;