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

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.js CHANGED
@@ -1787,7 +1787,11 @@ var pickupAdapter = {
1787
1787
  // src/params/adapters/orderForm/utils.ts
1788
1788
  var getOrderFormItems = (orderForm) => {
1789
1789
  const idSelected = orderForm == null ? void 0 : orderForm.selected;
1790
- return idSelected ? orderForm.items.filter((item) => item.id === idSelected) : orderForm.items;
1790
+ const isMultipleRemove = orderForm == null ? void 0 : orderForm.multipleRemove;
1791
+ return idSelected ? orderForm.items.filter((item) => item.id === idSelected).map((i) => {
1792
+ if (isMultipleRemove) return i;
1793
+ return { ...i, quantity: 1 };
1794
+ }) : orderForm.items;
1791
1795
  };
1792
1796
  var getItemCategory6 = (item) => {
1793
1797
  var _a;
@@ -1814,17 +1818,19 @@ function getItemShippingTier2(orderForm, item) {
1814
1818
  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;
1815
1819
  }
1816
1820
  var getPaymentType2 = (context) => {
1817
- var _a, _b, _c;
1821
+ var _a, _b, _c, _d;
1818
1822
  if (context.payment_type) return context.payment_type;
1819
1823
  if (!context.orderForm) return null;
1820
- const payments = ((_a = context.orderForm.paymentData) == null ? void 0 : _a.payments) || [];
1821
- const systems = ((_b = context.orderForm.paymentData) == null ? void 0 : _b.paymentSystems) || [];
1824
+ const giftCards = ((_a = context.orderForm.paymentData) == null ? void 0 : _a.giftCards) || [];
1825
+ if (giftCards.some((g) => g == null ? void 0 : g.inUse)) return "vale";
1826
+ const payments = ((_b = context.orderForm.paymentData) == null ? void 0 : _b.payments) || [];
1827
+ const systems = ((_c = context.orderForm.paymentData) == null ? void 0 : _c.paymentSystems) || [];
1822
1828
  if (!payments.length || !systems.length) return null;
1823
1829
  const selectedPayment = payments.find((p) => p == null ? void 0 : p.paymentSystem) || payments[0];
1824
1830
  const id = String((selectedPayment == null ? void 0 : selectedPayment.paymentSystem) || "").trim();
1825
1831
  if (!id) return null;
1826
1832
  const system = systems.find((s) => String(s.id) === id);
1827
- const name = ((_c = system == null ? void 0 : system.name) == null ? void 0 : _c.toLowerCase()) || "";
1833
+ const name = ((_d = system == null ? void 0 : system.name) == null ? void 0 : _d.toLowerCase()) || "";
1828
1834
  const match = paymentTypeMap.find(([key]) => name.includes(key));
1829
1835
  return match ? match[1] : null;
1830
1836
  };
@@ -1842,7 +1848,7 @@ var orderFormAdapter = {
1842
1848
  index: (_c = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.index) != null ? _c : index + 1,
1843
1849
  item_brand: (_e = (_d = item.additionalInfo) == null ? void 0 : _d.brandName) != null ? _e : null,
1844
1850
  item_name: (_f = item == null ? void 0 : item.name.replace(item == null ? void 0 : item.skuName, "").trim()) != null ? _f : null,
1845
- price: (item == null ? void 0 : item.price) / 100,
1851
+ price: (item == null ? void 0 : item.sellingPrice) / 100,
1846
1852
  discount: ((item == null ? void 0 : item.listPrice) - (item == null ? void 0 : item.sellingPrice)) / 100,
1847
1853
  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,
1848
1854
  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,
@@ -1879,20 +1885,16 @@ var orderFormAdapter = {
1879
1885
  var _a;
1880
1886
  if (context == null ? void 0 : context.value) return context.value;
1881
1887
  if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1882
- 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);
1888
+ 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);
1883
1889
  },
1884
1890
  payment_type: getPaymentType2,
1885
1891
  total_discount: (context) => {
1886
- var _a, _b;
1892
+ var _a, _b, _c;
1887
1893
  if (context == null ? void 0 : context.total_discount) return context.total_discount;
1888
1894
  if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1889
- const totalsList = ((_b = context.orderForm) == null ? void 0 : _b.totalizers) || [];
1890
- const totalDiscount = getOrderFormItems(context.orderForm).reduce((acc, item) => {
1891
- const unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
1892
- return acc + unitDiscount * item.quantity;
1893
- }, 0);
1894
- const discounts = totalsList.find((t) => t.id === "Discounts");
1895
- return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
1895
+ const totalizers = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.totalizers;
1896
+ const productDiscount = ((_c = totalizers.find((t) => t.id === "Discounts")) == null ? void 0 : _c.value) || 0;
1897
+ return Math.abs(productDiscount) / 100 || null;
1896
1898
  },
1897
1899
  subtotal: (context) => {
1898
1900
  var _a, _b;