@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,13 +1,13 @@
1
- import { jsxs as c, jsx as o } from "react/jsx-runtime";
2
- import { SuccessIcon as r } from "../../../assets/svgs/SuccessIcon.js";
3
- import { ErrorIcon as e } from "../../../assets/svgs/ErrorIcon.js";
4
- const m = ({ type: s }) => s === "success" || s === "removed" ? /* @__PURE__ */ c("div", { className: "applied-coupon-badge success-coupon", children: [
5
- /* @__PURE__ */ o("span", { children: /* @__PURE__ */ o(r, {}) }),
6
- s === "success" ? "Cupom aplicado com sucesso" : "Cupom removido com sucesso"
7
- ] }) : /* @__PURE__ */ c("div", { className: "applied-coupon-badge error-coupon", children: [
8
- /* @__PURE__ */ o("span", { children: /* @__PURE__ */ o(e, {}) }),
9
- "Não foi possível aplicar o cupom. Tente aplicar mais tarde."
1
+ import { jsxs as i, jsx as n } from "react/jsx-runtime";
2
+ import { CheckMarkBoxIcon as t } from "../../../assets/svgs/CheckMarkBoxIcon.js";
3
+ import { WarningIcon as a } from "../../../assets/svgs/WarningIcon.js";
4
+ const c = {
5
+ applied: /* @__PURE__ */ n(t, {}),
6
+ warning: /* @__PURE__ */ n(a, {})
7
+ }, s = ({ type: r, children: o }) => r === "" ? null : /* @__PURE__ */ i("div", { className: `alert ${r}`, children: [
8
+ c[r],
9
+ o
10
10
  ] });
11
11
  export {
12
- m as Alert
12
+ s as Alert
13
13
  };
@@ -1,27 +1,10 @@
1
1
  import { CouponType } from '../types/CouponType';
2
- import { View } from '../types/Views';
3
- import { AlertType } from './Alert';
2
+ import { ChangeCouponParams } from '../hooks/useCoupons';
4
3
 
5
4
  export interface CouponCardProps {
6
- account: string;
7
- orderFormId: string;
8
- hasItemsInCart: boolean;
9
- isIO?: boolean;
10
5
  item: CouponType;
11
- firstCouponName: string;
12
- secondCouponName: string;
13
- replaceCoupon: boolean;
14
- setView: (view: View) => void;
15
- setFirstCouponName: (firstCouponName: string) => void;
16
- setSecondCouponName: (secondCouponName: string) => void;
17
- setActiveRule: (activeRule: boolean) => void;
18
- setDataItem: (dataItem: CouponType) => void;
19
- setReplaceCoupon: (replaceCoupon: boolean) => void;
20
- setAlert: (errorMessage: boolean) => void;
21
- setType: (type: AlertType) => void;
22
- setIsCloseModalEmpty: (isCloseModalEmpty: boolean) => void;
23
- genericTaggingEvent?: (name: string, params: object) => void;
24
- addCouponMutation?: any;
25
- removeCouponMutation?: any;
6
+ currentCoupon: string;
7
+ changeCoupon: (params: ChangeCouponParams) => Promise<void>;
8
+ isLoading: boolean;
26
9
  }
27
- export declare const CouponCard: ({ orderFormId, hasItemsInCart, isIO, item, firstCouponName, secondCouponName, replaceCoupon, setView, setActiveRule, setDataItem, setFirstCouponName, setSecondCouponName, setReplaceCoupon, setAlert, setType, setIsCloseModalEmpty, genericTaggingEvent, addCouponMutation, removeCouponMutation }: CouponCardProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const CouponCard: ({ item, currentCoupon, changeCoupon, isLoading }: CouponCardProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,142 +1,88 @@
1
- import { jsxs as p, jsx as c } from "react/jsx-runtime";
2
- import { useState as V, useEffect as q } from "react";
3
- import { addCoupon as B } from "../api/addCoupon.js";
4
- import { CouponIcon as G } from "../../../assets/svgs/CouponIcon.js";
5
- import { SuccessIcon as H } from "../../../assets/svgs/SuccessIcon.js";
6
- import { removeCoupon as K } from "../api/removeCoupon.js";
7
- const Z = ({
8
- orderFormId: t,
9
- hasItemsInCart: D,
10
- isIO: r = !1,
11
- item: a,
12
- firstCouponName: s,
13
- secondCouponName: d,
14
- replaceCoupon: b,
15
- setView: R,
16
- setActiveRule: z,
17
- setDataItem: J,
18
- setFirstCouponName: L,
19
- setSecondCouponName: _,
20
- setReplaceCoupon: j,
21
- setAlert: f,
22
- setType: m,
23
- setIsCloseModalEmpty: y,
24
- genericTaggingEvent: o,
25
- addCouponMutation: S,
26
- removeCouponMutation: i
1
+ import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
+ import { useState as w, useRef as h, useEffect as m } from "react";
3
+ import { CouponIcon as g } from "../../../assets/svgs/CouponIcon.js";
4
+ import { CheckMarkIcon as x } from "../../../assets/svgs/CheckMarkIcon.js";
5
+ import { CloseIcon as b } from "../../../assets/svgs/CloseIcon.js";
6
+ const T = ({
7
+ item: o,
8
+ currentCoupon: t,
9
+ changeCoupon: f,
10
+ isLoading: N
27
11
  }) => {
28
- const [x, u] = V(!1), [k, w] = V(!1);
29
- q(() => {
30
- d.toLowerCase() !== a.couponName.toLowerCase() && u(!1), s && !d && s.toLowerCase() === a.couponName.toLowerCase() && u(!0), s && d && b && d.toLowerCase() === a.couponName.toLowerCase() && A(d);
31
- }, [s, d, b]);
32
- const A = async (l) => {
33
- if (D)
34
- try {
35
- if (!s || s && b) {
36
- w(!0);
37
- const h = r ? await B(t, l) : await S({
38
- input: {
39
- orderFormId: t,
40
- couponId: l
41
- }
42
- }), N = r ? h : JSON.parse(h.addCoupon.data);
43
- j(!1), L(l), _(""), N.error.length <= 0 ? (o == null || o("discount_coupon", {
44
- name: "cupom aplicado",
45
- cupomName: l
46
- }), m("success"), u(!0), r && window.location.reload()) : (o == null || o("discount_coupon", {
47
- name: "cupom aplicando - cupom incorreto ou expirado",
48
- cupomName: l,
49
- objectError: N.error
50
- }), m("error"), u(!1), L("")), f(!0);
51
- } else
52
- _(l), R("overwrite-view");
53
- } catch (h) {
54
- o == null || o("discount_coupon", {
55
- name: "problema na api",
56
- cupomName: l
57
- }), u(!1), m("error"), f(!0);
58
- } finally {
59
- w(!1);
60
- }
61
- else
62
- o == null || o("discount_coupon", {
63
- name: "Modal de cart vazio acionado"
64
- }), y(!0);
65
- }, M = async () => {
66
- if (D)
67
- try {
68
- w(!0), j(!1);
69
- const l = r ? await K(t) : await i({
70
- input: {
71
- orderFormId: t
12
+ const [i, d] = w(!1), a = h(null), r = h(null), s = !!(t && t.toLowerCase() === o.couponName.toLowerCase());
13
+ async function C() {
14
+ await f({
15
+ couponName: o.couponName,
16
+ isAdding: !s,
17
+ isFromForm: !1
18
+ });
19
+ }
20
+ function p() {
21
+ d(!i);
22
+ }
23
+ return m(() => {
24
+ var c;
25
+ if (i && r.current && a.current) {
26
+ const l = (c = a.current.clientWidth) != null ? c : 328;
27
+ r.current.style.width = `${l}px`;
28
+ }
29
+ }, [i]), m(() => {
30
+ const c = (l) => {
31
+ var u;
32
+ r.current && (l == null ? void 0 : l.target) instanceof Node && !((u = r.current) != null && u.contains(l == null ? void 0 : l.target)) && d(!1);
33
+ };
34
+ return i ? document.addEventListener("mousedown", c) : document.removeEventListener("mousedown", c), () => {
35
+ document.removeEventListener("mousedown", c);
36
+ };
37
+ }, [i]), /* @__PURE__ */ e("div", { className: "coupon-wrapper", ref: a, children: /* @__PURE__ */ n("div", { className: `container-card-coupon ${s ? "active" : ""}`, children: [
38
+ /* @__PURE__ */ n("div", { className: "card-coupon-content", children: [
39
+ /* @__PURE__ */ n("div", { className: "text-container", children: [
40
+ /* @__PURE__ */ n("div", { children: [
41
+ /* @__PURE__ */ n("div", { className: "container-title", children: [
42
+ /* @__PURE__ */ e(g, {}),
43
+ /* @__PURE__ */ e("h3", { className: "title", children: o.couponName }),
44
+ o.couponValue && /* @__PURE__ */ e("p", { className: "price-badge", children: o.couponValue })
45
+ ] }),
46
+ o.couponDescription && /* @__PURE__ */ e("h4", { className: "subtitle", children: o.couponDescription }),
47
+ o.couponExpirationDate && /* @__PURE__ */ n("h4", { className: "subtitle", children: [
48
+ "Válido até ",
49
+ o.couponExpirationDate
50
+ ] })
51
+ ] }),
52
+ /* @__PURE__ */ e(
53
+ "button",
54
+ {
55
+ className: `select-coupon ${s ? "applied" : ""}`,
56
+ onClick: C,
57
+ disabled: N,
58
+ children: s && /* @__PURE__ */ e(x, {})
72
59
  }
73
- }), h = r ? l : JSON.parse(l.removeCoupon.data);
74
- h.error.length <= 0 ? (o == null || o("discount_coupon", {
75
- name: "cupom removido com sucesso",
76
- cupomName: s
77
- }), m("removed"), u(!1), L(""), _(""), r && window.location.reload()) : (o == null || o("discount_coupon", {
78
- name: "algum problema na remoção do cupom",
79
- cupomName: s,
80
- objectError: h.error
81
- }), m("error"), u(!0)), f(!0);
82
- } catch (l) {
83
- o == null || o("discount_coupon", {
84
- name: "problema na api - na remoção do cupom",
85
- cupomName: s
86
- }), m("error"), u(!0), f(!0);
87
- } finally {
88
- w(!1);
89
- }
90
- else
91
- o == null || o("discount_coupon", {
92
- name: "Modal de cart vazio acionado"
93
- }), y(!0);
94
- }, $ = () => {
95
- z(!0), J(a), R("rules-view");
96
- };
97
- return /* @__PURE__ */ p("div", { className: `container-card-coupon ${x ? "active" : ""}`, children: [
98
- /* @__PURE__ */ p("div", { className: "text-container", children: [
99
- /* @__PURE__ */ p("div", { className: "container-title", children: [
100
- /* @__PURE__ */ c(G, { width: 20, height: 16 }),
101
- /* @__PURE__ */ c("h3", { className: "title", children: a.couponName })
60
+ )
102
61
  ] }),
103
- a.couponValue && /* @__PURE__ */ p("p", { className: "price-badge", children: [
104
- "- ",
105
- a.couponValue
106
- ] }),
107
- a.couponDescription && /* @__PURE__ */ c("h4", { className: "subtitle", children: a.couponDescription }),
108
- a.couponExpirationDate && /* @__PURE__ */ p("h4", { className: "subtitle", children: [
109
- "Válido até ",
110
- a.couponExpirationDate
111
- ] })
62
+ /* @__PURE__ */ e("div", { className: `ellipse left ${s ? "applied" : ""}` }),
63
+ /* @__PURE__ */ e("div", { className: `ellipse right ${s ? "applied" : ""}` })
112
64
  ] }),
113
- /* @__PURE__ */ c("div", { className: "vertical-line" }),
114
- /* @__PURE__ */ p("div", { className: "buttons-container", children: [
115
- x && /* @__PURE__ */ p("button", { className: "applied-coupon", children: [
116
- /* @__PURE__ */ c("span", { className: "applied-coupon-span", children: /* @__PURE__ */ c(H, {}) }),
117
- "Aplicado"
65
+ o.couponRules && o.couponRules.length > 0 && /* @__PURE__ */ e("button", { className: "see-rules", onClick: p, children: "*Termos & condições" }),
66
+ i && /* @__PURE__ */ n("div", { className: "tooltip-rules", ref: r, children: [
67
+ /* @__PURE__ */ n("div", { className: "tooltip-rules-header", children: [
68
+ /* @__PURE__ */ e("h4", { children: "Termos e Condições" }),
69
+ /* @__PURE__ */ e("button", { onClick: p, children: /* @__PURE__ */ e(b, {}) })
118
70
  ] }),
119
- x ? /* @__PURE__ */ c(
120
- "button",
121
- {
122
- onClick: M,
123
- className: "remove-coupon",
124
- disabled: k,
125
- children: "Remover"
126
- }
127
- ) : /* @__PURE__ */ c(
128
- "button",
129
- {
130
- onClick: () => A(a.couponName),
131
- className: "apply-coupon",
132
- disabled: k,
133
- children: "Aplicar"
134
- }
135
- ),
136
- a.couponDescription && /* @__PURE__ */ c("a", { onClick: $, children: "Ver Regras" })
71
+ /* @__PURE__ */ e("p", { children: o.couponDescription }),
72
+ /* @__PURE__ */ n("ul", { children: [
73
+ o.couponRules.map((c) => /* @__PURE__ */ n("li", { children: [
74
+ "• ",
75
+ c
76
+ ] }, c)),
77
+ /* @__PURE__ */ n("li", { children: [
78
+ "• Válido até ",
79
+ o.couponExpirationDate,
80
+ "."
81
+ ] })
82
+ ] })
137
83
  ] })
138
- ] });
84
+ ] }) });
139
85
  };
140
86
  export {
141
- Z as CouponCard
87
+ T as CouponCard
142
88
  };
@@ -1,10 +1,10 @@
1
- import { jsxs as n, jsx as o } from "react/jsx-runtime";
2
- import { NoCouponsIcon as s } from "../../../assets/svgs/NoCouponIcon.js";
3
- const i = () => /* @__PURE__ */ n("div", { className: "noCoupons", children: [
4
- /* @__PURE__ */ o("h1", { className: "noCoupons-h3", children: "Não há cupons disponíveis no momento" }),
5
- /* @__PURE__ */ o(s, {}),
6
- /* @__PURE__ */ o("p", { className: "noCoupons-p", children: "Caso você tenha algum código de cupom em mãos, insira o código acima, ou entre no seu carrinho de compras e insira o código no campo ‘Cupom de Desconto’." })
1
+ import { jsxs as s, jsx as o } from "react/jsx-runtime";
2
+ import { NoCouponsIcon as n } from "../../../assets/svgs/NoCouponIcon.js";
3
+ const a = () => /* @__PURE__ */ s("div", { className: "noCoupons", children: [
4
+ /* @__PURE__ */ o("h3", { className: "noCoupons-h3", children: "Não há cupons disponíveis no momento" }),
5
+ /* @__PURE__ */ o(n, {}),
6
+ /* @__PURE__ */ o("p", { className: "noCoupons-p", children: "Caso você tenha algum código de cupom em mãos, insira o código acima, ou entre no seu carrinho de compras e insira o código no campo ‘Meus Cupons e Vale-compras’." })
7
7
  ] });
8
8
  export {
9
- i as NoCoupons
9
+ a as NoCoupons
10
10
  };
@@ -0,0 +1,34 @@
1
+ import { AlertType } from '../components/Alert';
2
+ import { CouponType } from '../types/CouponType';
3
+
4
+ export interface UseCouponsParams {
5
+ orderFormId: string;
6
+ hasItemsInCart: boolean;
7
+ builder: 'faststore' | 'app';
8
+ account: string;
9
+ isIO?: boolean;
10
+ activeOrderFormCoupon?: string;
11
+ genericTaggingEvent?: (name: string, params: object) => void;
12
+ couponsList?: CouponType[];
13
+ qtdCouponsView?: number;
14
+ getCouponsMutation?: any;
15
+ addCouponMutation?: any;
16
+ removeCouponMutation?: any;
17
+ }
18
+ export interface ChangeCouponParams {
19
+ couponName: string;
20
+ isAdding: boolean;
21
+ isFromForm: boolean;
22
+ }
23
+ export declare function useCoupons({ orderFormId, hasItemsInCart, builder, account, isIO, activeOrderFormCoupon, genericTaggingEvent, couponsList, qtdCouponsView, getCouponsMutation, addCouponMutation, removeCouponMutation }: UseCouponsParams): {
24
+ isLoadingCouponList: boolean;
25
+ coupons: CouponType[];
26
+ currentCoupon: string;
27
+ isLoadingButton: boolean;
28
+ inputCoupon: string;
29
+ isInputError: boolean;
30
+ showAlert: AlertType;
31
+ handleSubmit: (event: React.FormEvent<HTMLFormElement>) => Promise<void>;
32
+ handleChangeInput: (event: React.ChangeEvent<HTMLInputElement>) => void;
33
+ changeCoupon: ({ couponName, isAdding, isFromForm }: ChangeCouponParams) => Promise<void>;
34
+ };
@@ -0,0 +1,109 @@
1
+ import { useState as u, useEffect as D } from "react";
2
+ import { addCoupon as K } from "../api/addCoupon.js";
3
+ import { removeCoupon as P } from "../api/removeCoupon.js";
4
+ import { getCoupons as Q } from "../api/getCoupons.js";
5
+ function Z({
6
+ orderFormId: f,
7
+ hasItemsInCart: O,
8
+ builder: J,
9
+ account: c,
10
+ isIO: R = !1,
11
+ activeOrderFormCoupon: e,
12
+ genericTaggingEvent: s,
13
+ couponsList: w,
14
+ qtdCouponsView: L,
15
+ getCouponsMutation: h,
16
+ addCouponMutation: m,
17
+ removeCouponMutation: n
18
+ }) {
19
+ const [b, _] = u(!0), [d, C] = u([]), [j, y] = u(""), [q, $] = u(!1), [S, x] = u(""), [z, l] = u(!1), [k, I] = u("");
20
+ function G(o) {
21
+ o.preventDefault(), x(o.target.value);
22
+ }
23
+ async function H(o) {
24
+ if (o.preventDefault(), !S) {
25
+ l(!0);
26
+ return;
27
+ }
28
+ await B({
29
+ couponName: S,
30
+ isAdding: !0,
31
+ isFromForm: !0
32
+ });
33
+ }
34
+ async function B({
35
+ couponName: o,
36
+ isAdding: t,
37
+ isFromForm: p
38
+ }) {
39
+ if (I(""), l(!1), t && !O) {
40
+ s == null || s("discount_coupon", {
41
+ name: "Alerta de carrinho vazio acionado"
42
+ }), I("warning");
43
+ return;
44
+ }
45
+ try {
46
+ $(!0);
47
+ let r;
48
+ if (t) {
49
+ const a = m ? await m({
50
+ input: { orderFormId: f, couponId: o }
51
+ }) : await K(c, f, o);
52
+ r = m ? JSON.parse(a.addCoupon.data) : a;
53
+ } else {
54
+ const a = n ? await n({ input: { orderFormId: f } }) : await P(c, f);
55
+ r = n ? JSON.parse(a.removeCoupon.data) : a;
56
+ }
57
+ r.error.length <= 0 ? (s == null || s("discount_coupon", {
58
+ name: `Cupom ${t ? "aplicado" : "removido"}`,
59
+ couponName: o
60
+ }), y(t ? o : ""), I(t ? "applied" : ""), R && window.location.reload()) : (s == null || s("discount_coupon", {
61
+ name: `Erro ao ${t ? "aplicar" : "remover"} cupom`,
62
+ couponName: o,
63
+ objectError: r.error
64
+ }), y(t ? "" : o), p && l(!0));
65
+ } catch (r) {
66
+ s == null || s("discount_coupon", {
67
+ name: `Erro ao ${t ? "aplicar" : "remover"} cupom`,
68
+ couponName: o
69
+ }), p && l(!0);
70
+ } finally {
71
+ $(!1);
72
+ }
73
+ }
74
+ return D(() => {
75
+ e && y(e);
76
+ }, [e]), D(() => {
77
+ (async () => {
78
+ _(!0);
79
+ try {
80
+ const t = h ? await h({ input: { builder: J, couponsList: w } }) : await Q(c, J, w), p = h ? JSON.parse(t.getCoupons.data).coupons : t;
81
+ if (L) {
82
+ const r = p.slice(0, L);
83
+ C(r);
84
+ return;
85
+ }
86
+ C(p);
87
+ return;
88
+ } catch (t) {
89
+ C([]);
90
+ } finally {
91
+ _(!1);
92
+ }
93
+ })();
94
+ }, [JSON.stringify(w)]), {
95
+ isLoadingCouponList: b,
96
+ coupons: d,
97
+ currentCoupon: j,
98
+ isLoadingButton: q,
99
+ inputCoupon: S,
100
+ isInputError: z,
101
+ showAlert: k,
102
+ handleSubmit: H,
103
+ handleChangeInput: G,
104
+ changeCoupon: B
105
+ };
106
+ }
107
+ export {
108
+ Z as useCoupons
109
+ };
@@ -1,6 +1,6 @@
1
1
  export interface CouponType {
2
2
  couponName: string;
3
- couponValue: string;
3
+ couponValue?: string;
4
4
  couponDescription: string;
5
5
  couponRules: Array<string>;
6
6
  couponInitialDate: string;
@@ -0,0 +1,24 @@
1
+ import { ImageProps } from './components/VoucherRedeemedCard/VoucherRedeemedCard';
2
+ import { StatusMessageTryApplyProps } from './components/StatusMessageTryApply/StatusMessageTryApply';
3
+
4
+ interface VoucherRedeemedProps {
5
+ image: ImageProps;
6
+ }
7
+ interface DataCouponsCartonistProps {
8
+ isLoading: boolean;
9
+ couponsCartonist?: string[];
10
+ }
11
+ interface VouchersRedeemedProps {
12
+ brand: string;
13
+ voucher: VoucherRedeemedProps;
14
+ title: string;
15
+ text?: string;
16
+ dataCouponsCartonist?: DataCouponsCartonistProps;
17
+ couponApplied?: string;
18
+ statusMessage?: StatusMessageTryApplyProps;
19
+ onClick?: (couponId: string) => void;
20
+ availableAreaSizeToCarouselByItem?: number;
21
+ isShowEmpty?: boolean;
22
+ }
23
+ export declare function VouchersRedeemed({ brand, voucher, title, text, dataCouponsCartonist, couponApplied, statusMessage, onClick, availableAreaSizeToCarouselByItem, isShowEmpty }: VouchersRedeemedProps): import("react/jsx-runtime").JSX.Element | null;
24
+ export {};
@@ -0,0 +1,145 @@
1
+ var U = Object.defineProperty, W = Object.defineProperties;
2
+ var B = Object.getOwnPropertyDescriptors;
3
+ var v = Object.getOwnPropertySymbols;
4
+ var O = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
5
+ var R = (n, l, f) => l in n ? U(n, l, { enumerable: !0, configurable: !0, writable: !0, value: f }) : n[l] = f, S = (n, l) => {
6
+ for (var f in l || (l = {}))
7
+ O.call(l, f) && R(n, f, l[f]);
8
+ if (v)
9
+ for (var f of v(l))
10
+ F.call(l, f) && R(n, f, l[f]);
11
+ return n;
12
+ }, $ = (n, l) => W(n, B(l));
13
+ import { jsx as d, jsxs as j } from "react/jsx-runtime";
14
+ /* empty css */import G from "../../hooks/useWindowDimensions.js";
15
+ import { AdaptiveCarousel as J } from "../AdaptiveCarousel/AdaptiveCarousel.js";
16
+ import { VoucherRedeemedCard as K } from "./components/VoucherRedeemedCard/VoucherRedeemedCard.js";
17
+ import { useState as Q, useEffect as k, useMemo as X } from "react";
18
+ import { getCouponsClubCardByUser as Y } from "./api/getCouponsCartonistByUser.js";
19
+ import { getCouponPrice as Z } from "./utils/getCouponPrice.js";
20
+ import { StatusMessageTryApply as h } from "./components/StatusMessageTryApply/StatusMessageTryApply.js";
21
+ import { VouchersRedeemedSkeleton as o } from "./components/VouchersRedeemedSkeleton/VouchersRedeemedSkeleton.js";
22
+ import { VALID_VOUCHERS as z } from "./data/validVouchers.js";
23
+ import { setBoldTextParts as q } from "../../utils/setBoldTextParts.js";
24
+ function dl({
25
+ brand: n,
26
+ voucher: l,
27
+ title: f,
28
+ text: w,
29
+ dataCouponsCartonist: e,
30
+ couponApplied: s,
31
+ statusMessage: L,
32
+ onClick: E,
33
+ availableAreaSizeToCarouselByItem: N,
34
+ isShowEmpty: H
35
+ }) {
36
+ var I;
37
+ const [m, x] = Q({
38
+ isLoading: !e,
39
+ couponsCartonist: (I = e == null ? void 0 : e.couponsCartonist) != null ? I : []
40
+ }), { width: T } = G(), t = T && T < 768;
41
+ k(() => {
42
+ e && x(e);
43
+ }, [e]), k(() => {
44
+ async function r() {
45
+ var y;
46
+ try {
47
+ x({ isLoading: !0, couponsCartonist: [] });
48
+ const c = await Y();
49
+ x({
50
+ isLoading: !1,
51
+ couponsCartonist: (y = c == null ? void 0 : c.split("|")) != null ? y : []
52
+ });
53
+ } catch (c) {
54
+ x({ isLoading: !1, couponsCartonist: [] });
55
+ }
56
+ }
57
+ e || r();
58
+ }, [e]);
59
+ const i = X(() => {
60
+ var c;
61
+ if (m != null && m.isLoading)
62
+ return;
63
+ const r = m.couponsCartonist;
64
+ return r != null && r.length ? (c = r == null ? void 0 : r.map((g) => {
65
+ var _, b;
66
+ if (!z.includes(g))
67
+ return;
68
+ const P = Z(g);
69
+ return {
70
+ title: `Vale ${n} - Loja Online - ${P}`,
71
+ text: `${n} +amigo`,
72
+ informationText: `Código: ${g == null ? void 0 : g.toUpperCase()}`,
73
+ buttonText: "Aplicar no carrinho",
74
+ couponId: g == null ? void 0 : g.toLowerCase(),
75
+ image: {
76
+ src: (_ = l == null ? void 0 : l.image) == null ? void 0 : _.src,
77
+ alt: (b = l == null ? void 0 : l.image) == null ? void 0 : b.alt
78
+ }
79
+ };
80
+ })) == null ? void 0 : c.filter(Boolean) : [];
81
+ }, [m, n, l]);
82
+ return m != null && m.isLoading ? /* @__PURE__ */ d(
83
+ o,
84
+ {
85
+ sizeCard: {
86
+ desktop: { width: 193, height: 220 },
87
+ mobile: { width: 160, height: 208 }
88
+ },
89
+ availableAreaSizeToCarouselByItem: N
90
+ }
91
+ ) : H && !(i != null && i.length) ? /* @__PURE__ */ j("div", { id: "vouchersRedeemed", className: "club-card-vouchersRedeemed isEmpty", children: [
92
+ /* @__PURE__ */ d("h2", { className: "vouchersRedeemed-title", children: f }),
93
+ w && /* @__PURE__ */ d(
94
+ "p",
95
+ {
96
+ className: "vouchersRedeemed-subtitle",
97
+ dangerouslySetInnerHTML: { __html: q(w) }
98
+ }
99
+ ),
100
+ /* @__PURE__ */ d("div", { className: "vouchersRedeemed-empty", children: /* @__PURE__ */ d("p", { children: "Não há vales-compras disponíveis no momento" }) })
101
+ ] }) : !f || !(i != null && i.length) ? null : /* @__PURE__ */ j("div", { id: "vouchersRedeemed", className: "club-card-vouchersRedeemed", children: [
102
+ /* @__PURE__ */ d("h2", { className: "vouchersRedeemed-title", children: f }),
103
+ w && /* @__PURE__ */ d(
104
+ "p",
105
+ {
106
+ className: "vouchersRedeemed-subtitle",
107
+ dangerouslySetInnerHTML: { __html: q(w) }
108
+ }
109
+ ),
110
+ /* @__PURE__ */ d(
111
+ J,
112
+ {
113
+ quantity: i == null ? void 0 : i.length,
114
+ quantityToCarousel: N ? N + 1 : 6,
115
+ activeBlur: !1,
116
+ forceCarousel: !!t && (i == null ? void 0 : i.length) > 1,
117
+ propsCarousel: {
118
+ gapItems: 0,
119
+ itemWidthProp: t ? 160 : 193,
120
+ qtyItems: N
121
+ },
122
+ isNewDots: !0,
123
+ children: i == null ? void 0 : i.map((r, y) => /* @__PURE__ */ d(
124
+ K,
125
+ $(S({}, r), {
126
+ onClick: E,
127
+ buttonText: (s == null ? void 0 : s.toLowerCase()) === (r == null ? void 0 : r.couponId) ? "Vale aplicado!" : r == null ? void 0 : r.buttonText,
128
+ statusButton: (s == null ? void 0 : s.toLowerCase()) === (r == null ? void 0 : r.couponId) ? "clicked" : void 0
129
+ }),
130
+ y
131
+ ))
132
+ }
133
+ ),
134
+ L && /* @__PURE__ */ d(
135
+ h,
136
+ {
137
+ type: L == null ? void 0 : L.type,
138
+ text: L == null ? void 0 : L.text
139
+ }
140
+ )
141
+ ] });
142
+ }
143
+ export {
144
+ dl as VouchersRedeemed
145
+ };
@@ -0,0 +1 @@
1
+ export declare const getCouponsClubCardByUser: () => Promise<any>;
@@ -0,0 +1,20 @@
1
+ const n = async () => {
2
+ try {
3
+ return await fetch(
4
+ "/api/io/safedata/CL/documents/search?_fields=couponCartonist",
5
+ {
6
+ method: "GET",
7
+ headers: {
8
+ "Content-Type": "application/json",
9
+ Accept: "application/json"
10
+ }
11
+ }
12
+ ).then((t) => t.json());
13
+ } catch (o) {
14
+ console.error("Error getCouponsClubCardByUser");
15
+ return;
16
+ }
17
+ };
18
+ export {
19
+ n as getCouponsClubCardByUser
20
+ };