@plurix/ecom-components 1.14.3-com2034.0 → 1.15.0-loyalty.0

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.
Files changed (100) hide show
  1. package/dist/assets/svgs/CheckMarkBoxIcon.d.ts +1 -0
  2. package/dist/assets/svgs/CheckMarkBoxIcon.js +30 -0
  3. package/dist/assets/svgs/CheckMarkIcon.d.ts +1 -0
  4. package/dist/assets/svgs/CheckMarkIcon.js +23 -0
  5. package/dist/assets/svgs/CouponIcon.d.ts +1 -4
  6. package/dist/assets/svgs/CouponIcon.js +50 -14
  7. package/dist/assets/svgs/ErrorIcon.d.ts +1 -5
  8. package/dist/assets/svgs/ErrorIcon.js +26 -14
  9. package/dist/assets/svgs/ErrorIconV2.d.ts +1 -0
  10. package/dist/assets/svgs/ErrorIconV2.js +33 -0
  11. package/dist/assets/svgs/SuccessIconV2.d.ts +1 -0
  12. package/dist/assets/svgs/SuccessIconV2.js +30 -0
  13. package/dist/assets/svgs/WarningIconV2.d.ts +1 -0
  14. package/dist/assets/svgs/WarningIconV2.js +40 -0
  15. package/dist/hooks/useVerticalShelfCarouselProps.d.ts +4 -0
  16. package/dist/hooks/useVerticalShelfCarouselProps.js +14 -0
  17. package/dist/hooks/useWindowDimensions.d.ts +5 -0
  18. package/dist/hooks/useWindowDimensions.js +38 -0
  19. package/dist/main.d.ts +1 -0
  20. package/dist/main.js +19 -17
  21. package/dist/packages/AdaptiveCarousel/AdaptiveCarousel.d.ts +14 -0
  22. package/dist/packages/AdaptiveCarousel/AdaptiveCarousel.js +69 -0
  23. package/dist/packages/ChangeOrderModal/ChangeOrderModal.d.ts +3 -3
  24. package/dist/packages/ChangeOrderModal/ChangeOrderModal.js +73 -71
  25. package/dist/packages/ChangeOrderModal/components/ModalFooter.d.ts +1 -4
  26. package/dist/packages/ChangeOrderModal/components/ModalFooter.js +1 -3
  27. package/dist/packages/ChangeOrderModal/components/SimilarProductList.d.ts +3 -2
  28. package/dist/packages/ChangeOrderModal/components/SimilarProducts.d.ts +5 -4
  29. package/dist/packages/ChangeOrderModal/components/SimilarProducts.js +21 -21
  30. package/dist/packages/ChangeOrderModal/mocks.d.ts +0 -1
  31. package/dist/packages/ChangeOrderModal/mocks.js +0 -1
  32. package/dist/packages/Coupons/Coupons.d.ts +3 -17
  33. package/dist/packages/Coupons/Coupons.js +76 -114
  34. package/dist/packages/Coupons/api/addCoupon.d.ts +1 -1
  35. package/dist/packages/Coupons/api/addCoupon.js +7 -7
  36. package/dist/packages/Coupons/api/getCoupons.d.ts +1 -1
  37. package/dist/packages/Coupons/api/getCoupons.js +4 -4
  38. package/dist/packages/Coupons/api/removeCoupon.d.ts +1 -1
  39. package/dist/packages/Coupons/api/removeCoupon.js +6 -6
  40. package/dist/packages/Coupons/components/Alert.d.ts +4 -2
  41. package/dist/packages/Coupons/components/Alert.js +10 -10
  42. package/dist/packages/Coupons/components/CouponCard.d.ts +5 -22
  43. package/dist/packages/Coupons/components/CouponCard.js +79 -133
  44. package/dist/packages/Coupons/components/NoCoupons.js +7 -7
  45. package/dist/packages/Coupons/hooks/useCoupons.d.ts +34 -0
  46. package/dist/packages/Coupons/hooks/useCoupons.js +109 -0
  47. package/dist/packages/Coupons/types/CouponType.d.ts +1 -1
  48. package/dist/packages/VouchersRedeemed/VouchersRedeemed.d.ts +24 -0
  49. package/dist/packages/VouchersRedeemed/VouchersRedeemed.js +145 -0
  50. package/dist/packages/VouchersRedeemed/api/getCouponsCartonistByUser.d.ts +1 -0
  51. package/dist/packages/VouchersRedeemed/api/getCouponsCartonistByUser.js +20 -0
  52. package/dist/packages/VouchersRedeemed/components/StatusMessageTryApply/StatusMessageTryApply.d.ts +12 -0
  53. package/dist/packages/VouchersRedeemed/components/StatusMessageTryApply/StatusMessageTryApply.js +27 -0
  54. package/dist/packages/VouchersRedeemed/components/StatusMessageTryApply/index.d.ts +1 -0
  55. package/dist/packages/VouchersRedeemed/components/StatusMessageTryApply/index.js +4 -0
  56. package/dist/packages/VouchersRedeemed/components/VoucherRedeemedCard/VoucherRedeemedCard.d.ts +17 -0
  57. package/dist/packages/VouchersRedeemed/components/VoucherRedeemedCard/VoucherRedeemedCard.js +37 -0
  58. package/dist/packages/VouchersRedeemed/components/VoucherRedeemedCard/index.d.ts +1 -0
  59. package/dist/packages/VouchersRedeemed/components/VoucherRedeemedCard/index.js +4 -0
  60. package/dist/packages/VouchersRedeemed/components/VouchersRedeemedSkeleton/VouchersRedeemedSkeleton.d.ts +15 -0
  61. package/dist/packages/VouchersRedeemed/components/VouchersRedeemedSkeleton/VouchersRedeemedSkeleton.js +49 -0
  62. package/dist/packages/VouchersRedeemed/components/VouchersRedeemedSkeleton/index.d.ts +1 -0
  63. package/dist/packages/VouchersRedeemed/components/VouchersRedeemedSkeleton/index.js +4 -0
  64. package/dist/packages/VouchersRedeemed/data/validVouchers.d.ts +1 -0
  65. package/dist/packages/VouchersRedeemed/data/validVouchers.js +20 -0
  66. package/dist/packages/VouchersRedeemed/utils/getCouponPrice.d.ts +1 -0
  67. package/dist/packages/VouchersRedeemed/utils/getCouponPrice.js +8 -0
  68. package/dist/styles/adaptive-carousel.global.css +1 -0
  69. package/dist/styles/change-order-modal.global.css +1 -1
  70. package/dist/styles/coupons.global.css +1 -1
  71. package/dist/styles/vouchers-redeemed.global.css +1 -0
  72. package/dist/utils/carousel/carouselProps.d.ts +33 -0
  73. package/dist/utils/carousel/carouselProps.js +59 -0
  74. package/dist/utils/scroll/isScrollToEnd.d.ts +1 -0
  75. package/dist/utils/scroll/isScrollToEnd.js +4 -0
  76. package/dist/utils/setBoldTextParts.d.ts +1 -0
  77. package/dist/utils/setBoldTextParts.js +7 -0
  78. package/package.json +69 -69
  79. package/dist/packages/Coupons/components/Breadcrumb.d.ts +0 -6
  80. package/dist/packages/Coupons/components/Breadcrumb.js +0 -33
  81. package/dist/packages/Coupons/components/Modal.d.ts +0 -8
  82. package/dist/packages/Coupons/components/Modal.js +0 -62
  83. package/dist/packages/Coupons/components/ModalFooter.d.ts +0 -9
  84. package/dist/packages/Coupons/components/ModalFooter.js +0 -25
  85. package/dist/packages/Coupons/components/ModalHeader.d.ts +0 -6
  86. package/dist/packages/Coupons/components/ModalHeader.js +0 -25
  87. package/dist/packages/Coupons/types/Views.d.ts +0 -1
  88. package/dist/packages/Coupons/types/Views.js +0 -1
  89. package/dist/packages/Coupons/views/CouponsView.d.ts +0 -15
  90. package/dist/packages/Coupons/views/CouponsView.js +0 -131
  91. package/dist/packages/Coupons/views/EmptyCartView.d.ts +0 -6
  92. package/dist/packages/Coupons/views/EmptyCartView.js +0 -36
  93. package/dist/packages/Coupons/views/LoadingView.d.ts +0 -7
  94. package/dist/packages/Coupons/views/LoadingView.js +0 -39
  95. package/dist/packages/Coupons/views/OverwriteView.d.ts +0 -14
  96. package/dist/packages/Coupons/views/OverwriteView.js +0 -58
  97. package/dist/packages/Coupons/views/RulesView.d.ts +0 -13
  98. package/dist/packages/Coupons/views/RulesView.js +0 -49
  99. package/dist/packages/Coupons/views/index.d.ts +0 -5
  100. package/dist/packages/Coupons/views/index.js +0 -12
@@ -1,8 +1,8 @@
1
- import { jsx as i, jsxs as _, Fragment as q } from "react/jsx-runtime";
2
- import { useState as g, useEffect as v } from "react";
3
- import { Modal as D } from "../Modal/Modal.js";
4
- import { ProductSelected as L } from "./components/ProductSelected.js";
5
- import { SimilarProducts as R } from "./components/SimilarProducts.js";
1
+ import { jsx as a, jsxs as E, Fragment as J } from "react/jsx-runtime";
2
+ import { useState as f, useEffect as M } from "react";
3
+ import { Modal as _ } from "../Modal/Modal.js";
4
+ import { ProductSelected as v } from "./components/ProductSelected.js";
5
+ import { SimilarProducts as L } from "./components/SimilarProducts.js";
6
6
  import { ModalFooter as T } from "./components/ModalFooter.js";
7
7
  /* empty css */import { getProductsSimilars as $ } from "./api/getProductsSimilars.js";
8
8
  import z from "../../hooks/useAnalitcsEvents.js";
@@ -10,82 +10,84 @@ import { NoSimilarProduct as B } from "./components/NoSimilarProduct.js";
10
10
  import { getOrderForm as G } from "./api/getOrderForm.js";
11
11
  import { postChangeOrder as H } from "./api/postChangeOrder.js";
12
12
  import { Skeleton as K } from "../Skeleton/index.js";
13
- const no = ({
14
- selectedItem: t,
15
- postalCode: C,
16
- orderFormId: s,
17
- isClubClient: w,
18
- isOpen: x,
19
- environment: N,
20
- setIsOpen: e,
21
- saveSelectedSimilarProduct: m,
13
+ const ao = ({
14
+ selectedItem: o,
15
+ postalCode: S,
16
+ orderFormId: d,
17
+ isClubClient: O,
18
+ isOpen: y,
19
+ environment: b,
20
+ setIsOpen: p,
21
+ saveSelectedSimilarProduct: c,
22
22
  getOrderFormMutation: l,
23
- getProductsSimilarsMutation: P,
24
- postChangeOrderMutation: j
23
+ getProductsSimilarsMutation: C,
24
+ postChangeOrderMutation: F
25
25
  }) => {
26
- const [a, k] = g(), [A, h] = g(!1), r = N === "io", { genericTaggingEvent: E } = z(), [o, O] = g();
27
- v(() => {
26
+ const [s, P] = f(), [x, m] = f(!1), r = b === "io", { genericTaggingEvent: N } = z(), [t, g] = f({ itemId: "" });
27
+ M(() => {
28
28
  (async () => {
29
- var S, b;
30
- h(!0);
29
+ m(!0);
31
30
  try {
32
- const [p, c] = await Promise.all([
33
- $({
34
- postalCode: C,
35
- selectedItem: t,
36
- isIO: r,
37
- getProductsSimilarsMutation: P
38
- }),
39
- (async () => {
40
- const d = r && await G(s, r), M = l && await l({
41
- input: { orderFormId: s }
42
- }) || { getOrderForm: { data: "" } };
43
- return r ? d : JSON.parse(M.getOrderForm.data);
44
- })()
45
- ]), J = (p == null ? void 0 : p.products) || [];
46
- k(J);
47
- const n = ((b = (S = c == null ? void 0 : c.customData) == null ? void 0 : S.customApps) == null ? void 0 : b.find(
48
- (d) => d.id === "janis"
31
+ const i = await $({
32
+ postalCode: S,
33
+ selectedItem: o,
34
+ isIO: r,
35
+ getProductsSimilarsMutation: C
36
+ }), u = (i == null ? void 0 : i.products) || [];
37
+ P(u);
38
+ } finally {
39
+ m(!1);
40
+ }
41
+ })(), (async () => {
42
+ var i, u;
43
+ m(!0);
44
+ try {
45
+ const q = r && G(d, r), w = l && await l({
46
+ input: {
47
+ orderFormId: d
48
+ }
49
+ }) || { getOrderForm: { data: "" } }, e = r ? q : JSON.parse(w.getOrderForm.data), n = ((u = (i = e == null ? void 0 : e.customData) == null ? void 0 : i.customApps) == null ? void 0 : u.find(
50
+ (A) => A.id === "janis"
49
51
  )) || null;
50
- let f = {};
51
- n != null && n.fields.idSubstitutionCriterias && (f = JSON.parse(n.fields.idSubstitutionCriterias));
52
- const y = t == null ? void 0 : t.productOriginId;
53
- f[y] && O({
54
- itemId: `${f[y]}`
52
+ let h = {};
53
+ n != null && n.fields.idSubstitutionCriterias && (h = JSON.parse(
54
+ n == null ? void 0 : n.fields.idSubstitutionCriterias
55
+ ));
56
+ const k = o == null ? void 0 : o.productOriginId;
57
+ g({
58
+ itemId: `${h[k]}`
55
59
  });
56
60
  } finally {
57
- h(!1);
61
+ m(!1);
58
62
  }
59
63
  })();
60
64
  }, []);
61
- const F = () => {
62
- var u;
65
+ const j = () => {
63
66
  H(
64
- s,
67
+ d,
65
68
  r,
66
- t.productOriginId,
67
- (u = o == null ? void 0 : o.itemId) != null ? u : "",
68
- j
69
- ), o && (m == null || m(o), E("salvar_substituto", {
70
- name: t.name,
71
- replacement_item: o == null ? void 0 : o.name
72
- })), e(!1);
69
+ o.productOriginId,
70
+ t.itemId,
71
+ F
72
+ ), t && (c == null || c(t), N("salvar_substituto", {
73
+ name: o.name,
74
+ replacement_item: t == null ? void 0 : t.name
75
+ })), p(!1);
73
76
  };
74
- return /* @__PURE__ */ i(
75
- D,
77
+ return /* @__PURE__ */ a(
78
+ _,
76
79
  {
77
- isOpen: x,
78
- setIsOpen: e,
80
+ isOpen: y,
81
+ setIsOpen: p,
79
82
  className: "change-order-modal",
80
83
  title: "Produto com estoque baixo",
81
- Footer: a && a.length > 0 && /* @__PURE__ */ i(
84
+ Footer: s && s.length > 0 && /* @__PURE__ */ a(
82
85
  T,
83
86
  {
84
- saveSelectedSimilarProduct: F,
85
- similarProductSelect: o
87
+ saveSelectedSimilarProduct: j
86
88
  }
87
89
  ),
88
- children: A ? /* @__PURE__ */ i(
90
+ children: x ? /* @__PURE__ */ a(
89
91
  K,
90
92
  {
91
93
  width: r ? "100%" : "90%",
@@ -94,21 +96,21 @@ const no = ({
94
96
  margin: "auto",
95
97
  animation: !0
96
98
  }
97
- ) : /* @__PURE__ */ _(q, { children: [
98
- t && /* @__PURE__ */ i(L, { selectedItem: t }),
99
- a && a.length > 0 ? /* @__PURE__ */ i(
100
- R,
99
+ ) : /* @__PURE__ */ E(J, { children: [
100
+ o && /* @__PURE__ */ a(v, { selectedItem: o }),
101
+ s && s.length > 0 ? /* @__PURE__ */ a(
102
+ L,
101
103
  {
102
- isClubClient: w,
103
- similarProductSelect: o,
104
- setSimilarProductSelect: O,
105
- products: a
104
+ isClubClient: O,
105
+ similarProductSelect: t,
106
+ setSimilarProductSelect: g,
107
+ products: s
106
108
  }
107
- ) : /* @__PURE__ */ i(B, {})
109
+ ) : /* @__PURE__ */ a(B, {})
108
110
  ] })
109
111
  }
110
112
  );
111
113
  };
112
114
  export {
113
- no as ChangeOrderModal
115
+ ao as ChangeOrderModal
114
116
  };
@@ -1,6 +1,3 @@
1
- import { SimilarProducts } from '../../../main';
2
-
3
- export declare const ModalFooter: ({ saveSelectedSimilarProduct, similarProductSelect }: {
1
+ export declare const ModalFooter: ({ saveSelectedSimilarProduct }: {
4
2
  saveSelectedSimilarProduct?: () => void;
5
- similarProductSelect: SimilarProducts | undefined;
6
3
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,11 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
2
  const t = ({
3
- saveSelectedSimilarProduct: o,
4
- similarProductSelect: r
3
+ saveSelectedSimilarProduct: o
5
4
  }) => /* @__PURE__ */ n("div", { className: "change-order-moda-footer", children: /* @__PURE__ */ n(
6
5
  "button",
7
6
  {
8
7
  onClick: () => o == null ? void 0 : o(),
9
8
  className: "change-order-save-buttom",
10
- disabled: !r,
11
9
  children: "Salvar Substituto"
12
10
  }
13
11
  ) });
@@ -1,8 +1,9 @@
1
+ import { Dispatch, SetStateAction } from 'react';
1
2
  import { SimilarProducts } from '../../../types/ChangeOrderModal';
2
3
 
3
4
  export declare const SimilarProductItem: ({ similarProduct, similarProductSelect, setSimilarProductSelect, isClubClient }: {
4
- similarProductSelect: SimilarProducts | undefined;
5
- setSimilarProductSelect: (similarProductSelect: SimilarProducts) => void;
5
+ similarProductSelect: SimilarProducts;
6
+ setSimilarProductSelect: Dispatch<SetStateAction<SimilarProducts>>;
6
7
  similarProduct: SimilarProducts;
7
8
  isClubClient?: boolean;
8
9
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,11 @@
1
+ import { Dispatch, SetStateAction } from 'react';
1
2
  import { SimilarProducts as SimilarProductProps } from '../../../types/ChangeOrderModal';
2
3
 
3
4
  interface Props {
4
- products: SimilarProductProps[];
5
- similarProductSelect: SimilarProductProps | undefined;
6
- setSimilarProductSelect: (similiarProductSelect: SimilarProductProps | undefined) => void;
5
+ products?: SimilarProductProps[];
6
+ similarProductSelect: SimilarProductProps;
7
+ setSimilarProductSelect: Dispatch<SetStateAction<SimilarProductProps>>;
7
8
  isClubClient?: boolean;
8
9
  }
9
- export declare const SimilarProducts: ({ products, isClubClient, similarProductSelect, setSimilarProductSelect }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const SimilarProducts: ({ products, isClubClient, similarProductSelect, setSimilarProductSelect }: Props) => import("react/jsx-runtime").JSX.Element | null;
10
11
  export {};
@@ -1,35 +1,35 @@
1
- import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
- import { Icons as c } from "../assets/icons.js";
3
- import { SimilarProductItem as e } from "./SimilarProductList.js";
4
- const u = ({
1
+ import { jsxs as r, jsx as i } from "react/jsx-runtime";
2
+ import { Icons as h } from "../assets/icons.js";
3
+ import { SimilarProductItem as t } from "./SimilarProductList.js";
4
+ const I = ({
5
5
  products: m,
6
- isClubClient: a,
7
- similarProductSelect: o,
8
- setSimilarProductSelect: s
9
- }) => /* @__PURE__ */ i("section", { className: "change-order-similar-products", children: [
10
- /* @__PURE__ */ r("h3", { className: "title", children: "Na falta substitua por:" }),
11
- /* @__PURE__ */ r("div", { className: "similar-product-list", children: m.map((t) => /* @__PURE__ */ r(
12
- e,
6
+ isClubClient: s,
7
+ similarProductSelect: a,
8
+ setSimilarProductSelect: n
9
+ }) => m != null && m.length ? /* @__PURE__ */ r("section", { className: "change-order-similar-products", children: [
10
+ /* @__PURE__ */ i("h3", { className: "title", children: "Na falta substitua por:" }),
11
+ /* @__PURE__ */ i("div", { className: "similar-product-list", children: m.map((o) => /* @__PURE__ */ i(
12
+ t,
13
13
  {
14
- isClubClient: a,
15
- similarProductSelect: o,
16
- setSimilarProductSelect: s,
17
- similarProduct: t
14
+ isClubClient: s,
15
+ similarProductSelect: a,
16
+ setSimilarProductSelect: n,
17
+ similarProduct: o
18
18
  },
19
- t.itemId
19
+ o.itemId
20
20
  )) }),
21
- o && /* @__PURE__ */ i(
21
+ a && /* @__PURE__ */ r(
22
22
  "button",
23
23
  {
24
- onClick: () => s(void 0),
24
+ onClick: () => n == null ? void 0 : n({ itemId: "" }),
25
25
  className: "remove-buttom",
26
26
  children: [
27
- /* @__PURE__ */ r(c, { iconId: "Trash" }),
27
+ /* @__PURE__ */ i(h, { iconId: "Trash" }),
28
28
  " Remover substituto"
29
29
  ]
30
30
  }
31
31
  )
32
- ] });
32
+ ] }) : null;
33
33
  export {
34
- u as SimilarProducts
34
+ I as SimilarProducts
35
35
  };
@@ -1,5 +1,4 @@
1
1
  export declare const productSelectedMock: {
2
- id: string;
3
2
  imageUrl: string;
4
3
  name: string;
5
4
  quantity: number;
@@ -1,5 +1,4 @@
1
1
  const e = {
2
- id: "product-001",
3
2
  imageUrl: "https://smrholding.vteximg.com.br/arquivos/ids/157320-55-55/7891150061040_01.jpg?v=637994761386800000",
4
3
  name: "Sorvete Ovomaltine Kibon 800mL",
5
4
  quantity: 1,
@@ -1,20 +1,6 @@
1
- import { CouponType } from './types/CouponType';
1
+ import { UseCouponsParams } from './hooks/useCoupons';
2
2
 
3
- interface CouponsProps {
4
- orderFormId: string;
5
- hasItemsInCart: boolean;
6
- builder: 'faststore' | 'app';
7
- account: string;
8
- isIO?: boolean;
9
- closeIOModal?: () => void;
10
- activeOrderFormCoupon?: string;
11
- genericTaggingEvent?: (name: string, params: object) => void;
12
- disableFirstEmptyModal?: boolean;
13
- couponsList?: CouponType[];
14
- qtdCouponsView?: number;
15
- getCouponsMutation?: any;
16
- addCouponMutation?: any;
17
- removeCouponMutation?: any;
3
+ interface CouponsProps extends UseCouponsParams {
18
4
  }
19
- export declare const Coupons: ({ orderFormId, hasItemsInCart, builder, account, isIO, closeIOModal, activeOrderFormCoupon, genericTaggingEvent, disableFirstEmptyModal, couponsList, qtdCouponsView, getCouponsMutation, addCouponMutation, removeCouponMutation }: CouponsProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const Coupons: (props: CouponsProps) => import("react/jsx-runtime").JSX.Element;
20
6
  export {};
@@ -1,120 +1,82 @@
1
- import { jsx as e, jsxs as P } from "react/jsx-runtime";
2
- import { useState as t, useEffect as h } from "react";
3
- import { LoadingView as Q } from "./views/LoadingView.js";
4
- import { CouponsView as U } from "./views/CouponsView.js";
5
- import { RulesView as W } from "./views/RulesView.js";
6
- import { OverwriteView as X } from "./views/OverwriteView.js";
7
- import { EmptyCartView as Y } from "./views/EmptyCartView.js";
8
- import { getCoupons as Z } from "./api/getCoupons.js";
9
- /* empty css */const to = ({
10
- orderFormId: j,
11
- hasItemsInCart: f,
12
- builder: l,
13
- account: A,
14
- isIO: o = !1,
15
- closeIOModal: r,
16
- activeOrderFormCoupon: n,
17
- genericTaggingEvent: s,
18
- disableFirstEmptyModal: J,
19
- couponsList: p,
20
- qtdCouponsView: w,
21
- getCouponsMutation: q,
22
- addCouponMutation: D,
23
- removeCouponMutation: L
24
- }) => {
25
- const [k, C] = t(!0), [z, a] = t([]), [u, c] = t("coupons-view"), [B, N] = t(!1), [d, y] = t(!1), [v, R] = t(""), [m, V] = t(""), [E, S] = t(
26
- !J
27
- ), [G, H] = t();
28
- return h(() => {
29
- n && R(n);
30
- }, [n]), h(() => {
31
- (async () => {
32
- C(!0);
33
- try {
34
- const i = o ? await Z(l, p) : await q({
35
- input: {
36
- builder: l,
37
- couponsList: p
38
- }
39
- }), x = o ? i : JSON.parse(i.getCoupons.data).coupons;
40
- if (w) {
41
- const K = x.slice(0, w);
42
- a(K);
43
- return;
44
- }
45
- a(x);
46
- return;
47
- } catch (i) {
48
- a([]);
49
- } finally {
50
- C(!1);
51
- }
52
- })();
53
- }, [JSON.stringify(p)]), k ? /* @__PURE__ */ e("div", { className: "coupons-container", children: /* @__PURE__ */ e(
54
- Q,
1
+ import { jsx as o, jsxs as e, Fragment as p } from "react/jsx-runtime";
2
+ import { Skeleton as C } from "../Skeleton/index.js";
3
+ import { ErrorIcon as f } from "../../assets/svgs/ErrorIcon.js";
4
+ import { CouponCard as N } from "./components/CouponCard.js";
5
+ import { Alert as v } from "./components/Alert.js";
6
+ import { NoCoupons as b } from "./components/NoCoupons.js";
7
+ import { useCoupons as S } from "./hooks/useCoupons.js";
8
+ /* empty css */const k = (r) => {
9
+ const { isIO: l } = r, {
10
+ isLoadingCouponList: m,
11
+ coupons: i,
12
+ currentCoupon: a,
13
+ inputCoupon: u,
14
+ isLoadingButton: c,
15
+ isInputError: s,
16
+ showAlert: n,
17
+ handleSubmit: d,
18
+ handleChangeInput: h,
19
+ changeCoupon: g
20
+ } = S(r);
21
+ return m ? /* @__PURE__ */ o("div", { className: "coupons-container", children: /* @__PURE__ */ o(
22
+ C,
55
23
  {
56
- isIO: o,
57
- closeIOModal: r,
58
- genericTaggingEvent: s
24
+ width: "100%",
25
+ height: 600,
26
+ backgroundColor: "var(--color-grayScale-faded)",
27
+ margin: "auto",
28
+ animation: !0
59
29
  }
60
- ) }) : /* @__PURE__ */ P("div", { className: "coupons-container", children: [
61
- (!o || o && u === "coupons-view") && /* @__PURE__ */ e(
62
- U,
63
- {
64
- removeCouponMutation: L,
65
- addCouponMutation: D,
66
- orderFormId: j,
67
- hasItemsInCart: f,
68
- account: A,
69
- isIO: o,
70
- closeIOModal: r,
71
- coupons: z,
72
- firstCouponName: v,
73
- secondCouponName: m,
74
- replaceCoupon: d,
75
- setView: c,
76
- setFirstCouponName: R,
77
- setSecondCouponName: V,
78
- setActiveRule: N,
79
- setDataItem: H,
80
- setReplaceCoupon: y,
81
- setIsCloseModalEmpty: S,
82
- genericTaggingEvent: s
83
- }
84
- ),
85
- (!o || o && u === "rules-view") && B && /* @__PURE__ */ e(
86
- W,
87
- {
88
- dataItem: G,
89
- setActiveRule: N,
90
- setView: c,
91
- isIO: o,
92
- closeIOModal: r,
93
- genericTaggingEvent: s
94
- }
95
- ),
96
- (!o || o && u === "overwrite-view") && m && !d && /* @__PURE__ */ e(
97
- X,
98
- {
99
- firstCouponName: v,
100
- secondCouponName: m,
101
- setView: c,
102
- setReplaceCoupon: y,
103
- setSecondCouponName: V,
104
- isIO: o,
105
- closeIOModal: r,
106
- genericTaggingEvent: s
107
- }
108
- ),
109
- !f && E && /* @__PURE__ */ e(
110
- Y,
111
- {
112
- setIsCloseModalEmpty: S,
113
- genericTaggingEvent: s
114
- }
115
- )
30
+ ) }) : /* @__PURE__ */ e("div", { className: "coupons-container", children: [
31
+ /* @__PURE__ */ e("div", { className: "form-coupons", children: [
32
+ /* @__PURE__ */ o("p", { children: "Digite o código do seu cupom ou selecione o que deseja resgatar:" }),
33
+ /* @__PURE__ */ e("form", { onSubmit: d, children: [
34
+ /* @__PURE__ */ o(
35
+ "input",
36
+ {
37
+ type: "text",
38
+ placeholder: "Digite o código",
39
+ value: u,
40
+ onChange: h,
41
+ className: s ? "error" : ""
42
+ }
43
+ ),
44
+ /* @__PURE__ */ o("button", { type: "submit", name: "Aplicar", disabled: c, children: "Aplicar" }),
45
+ s && /* @__PURE__ */ e("p", { className: "error-message", children: [
46
+ /* @__PURE__ */ o(f, {}),
47
+ " Não foi possível aplicar o Cupom"
48
+ ] })
49
+ ] })
50
+ ] }),
51
+ /* @__PURE__ */ o("div", { className: "container-title-coupons", children: i.length > 0 ? /* @__PURE__ */ e(p, { children: [
52
+ !l && /* @__PURE__ */ e(p, { children: [
53
+ /* @__PURE__ */ o("h2", { className: "container-main-title", children: "Seus Cupons de Descontos" }),
54
+ /* @__PURE__ */ o("p", { className: "container-main-subtitle", children: "Você precisa ter um cupom e pelo menos 1 item no carrinho para aplicar o desconto." })
55
+ ] }),
56
+ /* @__PURE__ */ o("div", { className: "container-coupons", children: i.map((t) => /* @__PURE__ */ o(
57
+ N,
58
+ {
59
+ item: t,
60
+ currentCoupon: a,
61
+ changeCoupon: g,
62
+ isLoading: c
63
+ },
64
+ t.couponName
65
+ )) }),
66
+ n && /* @__PURE__ */ e(v, { type: n, children: [
67
+ n === "applied" && /* @__PURE__ */ e("p", { children: [
68
+ "Cupom ",
69
+ /* @__PURE__ */ o("strong", { children: a }),
70
+ " aplicado com sucesso!"
71
+ ] }),
72
+ n === "warning" && /* @__PURE__ */ e("p", { children: [
73
+ "Para adicionar o cupom, é necessário que você tenha pelo menos ",
74
+ /* @__PURE__ */ o("strong", { children: "1 produto no carrinho." })
75
+ ] })
76
+ ] })
77
+ ] }) : /* @__PURE__ */ o(b, {}) })
116
78
  ] });
117
79
  };
118
80
  export {
119
- to as Coupons
81
+ k as Coupons
120
82
  };
@@ -1,3 +1,3 @@
1
1
  import { SetOrderFormCouponResponse } from '../types/SetOrderFormCouponResponse';
2
2
 
3
- export declare const addCoupon: (orderFormId: string, couponId: string) => Promise<SetOrderFormCouponResponse>;
3
+ export declare const addCoupon: (account: string, orderFormId: string, couponId: string) => Promise<SetOrderFormCouponResponse>;
@@ -1,14 +1,14 @@
1
1
  import r from "axios";
2
- const n = async (o, t) => {
3
- const { data: a } = await r.post(
4
- "/_v/faststoreapi/coupon/order",
2
+ const s = async (o, t, a) => {
3
+ const { data: p } = await r.post(
4
+ `https://${o}.vtex.app/api/coupon/order`,
5
5
  {
6
- orderFormId: o,
7
- couponId: t
6
+ orderFormId: t,
7
+ couponId: a
8
8
  }
9
9
  );
10
- return a;
10
+ return p;
11
11
  };
12
12
  export {
13
- n as addCoupon
13
+ s as addCoupon
14
14
  };
@@ -1,3 +1,3 @@
1
1
  import { CouponType } from '../types/CouponType';
2
2
 
3
- export declare const getCoupons: (builder: 'app' | 'faststore', couponsList?: CouponType[]) => Promise<CouponType[]>;
3
+ export declare const getCoupons: (account: string, builder: 'app' | 'faststore', couponsList?: CouponType[]) => Promise<CouponType[]>;
@@ -1,8 +1,8 @@
1
- import a from "axios";
2
- const c = async (s, o) => {
3
- const t = "/_v/faststoreapi/coupon/list", n = Math.random(), { data: r } = o ? await a.post(t, { couponsList: o }) : await a.get(t, { params: { builder: s, random: n } });
1
+ import o from "axios";
2
+ const e = async (n, p, t) => {
3
+ const a = `https://${n}.vtex.app/api/coupon/list`, s = Math.random(), { data: r } = t ? await o.post(a, { couponsList: t }) : await o.get(a, { params: { builder: p, random: s } });
4
4
  return r.coupons;
5
5
  };
6
6
  export {
7
- c as getCoupons
7
+ e as getCoupons
8
8
  };
@@ -1,3 +1,3 @@
1
1
  import { SetOrderFormCouponResponse } from '../types/SetOrderFormCouponResponse';
2
2
 
3
- export declare const removeCoupon: (orderFormId: string) => Promise<SetOrderFormCouponResponse>;
3
+ export declare const removeCoupon: (account: string, orderFormId: string) => Promise<SetOrderFormCouponResponse>;
@@ -1,12 +1,12 @@
1
- import a from "axios";
2
- const r = async (o) => {
3
- const { data: t } = await a.delete(
4
- "/_v/faststoreapi/coupon/order",
1
+ import e from "axios";
2
+ const r = async (o, t) => {
3
+ const { data: a } = await e.delete(
4
+ `https://${o}.vtex.app/api/coupon/order`,
5
5
  {
6
- data: { orderFormId: o }
6
+ data: { orderFormId: t }
7
7
  }
8
8
  );
9
- return t;
9
+ return a;
10
10
  };
11
11
  export {
12
12
  r as removeCoupon
@@ -1,6 +1,8 @@
1
+ /// <reference types="react" />
1
2
  interface AlertProps {
2
3
  type: AlertType;
4
+ children: React.ReactNode;
3
5
  }
4
- export type AlertType = '' | 'success' | 'removed' | 'error';
5
- export declare const Alert: ({ type }: AlertProps) => import("react/jsx-runtime").JSX.Element;
6
+ export type AlertType = '' | 'applied' | 'warning';
7
+ export declare const Alert: ({ type, children }: AlertProps) => import("react/jsx-runtime").JSX.Element | null;
6
8
  export {};