@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.cjs CHANGED
@@ -1816,7 +1816,11 @@ var pickupAdapter = {
1816
1816
  // src/params/adapters/orderForm/utils.ts
1817
1817
  var getOrderFormItems = (orderForm) => {
1818
1818
  const idSelected = orderForm == null ? void 0 : orderForm.selected;
1819
- return idSelected ? orderForm.items.filter((item) => item.id === idSelected) : orderForm.items;
1819
+ const isMultipleRemove = orderForm == null ? void 0 : orderForm.multipleRemove;
1820
+ return idSelected ? orderForm.items.filter((item) => item.id === idSelected).map((i) => {
1821
+ if (isMultipleRemove) return i;
1822
+ return { ...i, quantity: 1 };
1823
+ }) : orderForm.items;
1820
1824
  };
1821
1825
  var getItemCategory6 = (item) => {
1822
1826
  var _a;
@@ -1843,17 +1847,19 @@ function getItemShippingTier2(orderForm, item) {
1843
1847
  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;
1844
1848
  }
1845
1849
  var getPaymentType2 = (context) => {
1846
- var _a, _b, _c;
1850
+ var _a, _b, _c, _d;
1847
1851
  if (context.payment_type) return context.payment_type;
1848
1852
  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) || [];
1853
+ const giftCards = ((_a = context.orderForm.paymentData) == null ? void 0 : _a.giftCards) || [];
1854
+ if (giftCards.some((g) => g == null ? void 0 : g.inUse)) return "vale";
1855
+ const payments = ((_b = context.orderForm.paymentData) == null ? void 0 : _b.payments) || [];
1856
+ const systems = ((_c = context.orderForm.paymentData) == null ? void 0 : _c.paymentSystems) || [];
1851
1857
  if (!payments.length || !systems.length) return null;
1852
1858
  const selectedPayment = payments.find((p) => p == null ? void 0 : p.paymentSystem) || payments[0];
1853
1859
  const id = String((selectedPayment == null ? void 0 : selectedPayment.paymentSystem) || "").trim();
1854
1860
  if (!id) return null;
1855
1861
  const system = systems.find((s) => String(s.id) === id);
1856
- const name = ((_c = system == null ? void 0 : system.name) == null ? void 0 : _c.toLowerCase()) || "";
1862
+ const name = ((_d = system == null ? void 0 : system.name) == null ? void 0 : _d.toLowerCase()) || "";
1857
1863
  const match = paymentTypeMap.find(([key]) => name.includes(key));
1858
1864
  return match ? match[1] : null;
1859
1865
  };
@@ -1871,7 +1877,7 @@ var orderFormAdapter = {
1871
1877
  index: (_c = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.index) != null ? _c : index + 1,
1872
1878
  item_brand: (_e = (_d = item.additionalInfo) == null ? void 0 : _d.brandName) != null ? _e : null,
1873
1879
  item_name: (_f = item == null ? void 0 : item.name.replace(item == null ? void 0 : item.skuName, "").trim()) != null ? _f : null,
1874
- price: (item == null ? void 0 : item.price) / 100,
1880
+ price: (item == null ? void 0 : item.sellingPrice) / 100,
1875
1881
  discount: ((item == null ? void 0 : item.listPrice) - (item == null ? void 0 : item.sellingPrice)) / 100,
1876
1882
  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,
1877
1883
  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,
@@ -1908,20 +1914,16 @@ var orderFormAdapter = {
1908
1914
  var _a;
1909
1915
  if (context == null ? void 0 : context.value) return context.value;
1910
1916
  if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
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);
1917
+ 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);
1912
1918
  },
1913
1919
  payment_type: getPaymentType2,
1914
1920
  total_discount: (context) => {
1915
- var _a, _b;
1921
+ var _a, _b, _c;
1916
1922
  if (context == null ? void 0 : context.total_discount) return context.total_discount;
1917
1923
  if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1918
- const totalsList = ((_b = context.orderForm) == null ? void 0 : _b.totalizers) || [];
1919
- const totalDiscount = getOrderFormItems(context.orderForm).reduce((acc, item) => {
1920
- const unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
1921
- return acc + unitDiscount * item.quantity;
1922
- }, 0);
1923
- const discounts = totalsList.find((t) => t.id === "Discounts");
1924
- return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
1924
+ const totalizers = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.totalizers;
1925
+ const productDiscount = ((_c = totalizers.find((t) => t.id === "Discounts")) == null ? void 0 : _c.value) || 0;
1926
+ return Math.abs(productDiscount) / 100 || null;
1925
1927
  },
1926
1928
  subtotal: (context) => {
1927
1929
  var _a, _b;