@plurix/ecom-components 1.16.0-commerce.0 → 1.16.1-commerce

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 (85) 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/Coupons/Coupons.d.ts +3 -17
  24. package/dist/packages/Coupons/Coupons.js +76 -114
  25. package/dist/packages/Coupons/components/Alert.d.ts +4 -2
  26. package/dist/packages/Coupons/components/Alert.js +10 -10
  27. package/dist/packages/Coupons/components/CouponCard.d.ts +5 -22
  28. package/dist/packages/Coupons/components/CouponCard.js +79 -133
  29. package/dist/packages/Coupons/components/NoCoupons.js +7 -7
  30. package/dist/packages/Coupons/hooks/useCoupons.d.ts +33 -0
  31. package/dist/packages/Coupons/hooks/useCoupons.js +108 -0
  32. package/dist/packages/Coupons/types/CouponType.d.ts +1 -1
  33. package/dist/packages/VouchersRedeemed/VouchersRedeemed.d.ts +24 -0
  34. package/dist/packages/VouchersRedeemed/VouchersRedeemed.js +145 -0
  35. package/dist/packages/VouchersRedeemed/api/getCouponsCartonistByUser.d.ts +1 -0
  36. package/dist/packages/VouchersRedeemed/api/getCouponsCartonistByUser.js +20 -0
  37. package/dist/packages/VouchersRedeemed/components/StatusMessageTryApply/StatusMessageTryApply.d.ts +12 -0
  38. package/dist/packages/VouchersRedeemed/components/StatusMessageTryApply/StatusMessageTryApply.js +27 -0
  39. package/dist/packages/VouchersRedeemed/components/StatusMessageTryApply/index.d.ts +1 -0
  40. package/dist/packages/VouchersRedeemed/components/StatusMessageTryApply/index.js +4 -0
  41. package/dist/packages/VouchersRedeemed/components/VoucherRedeemedCard/VoucherRedeemedCard.d.ts +17 -0
  42. package/dist/packages/VouchersRedeemed/components/VoucherRedeemedCard/VoucherRedeemedCard.js +37 -0
  43. package/dist/packages/VouchersRedeemed/components/VoucherRedeemedCard/index.d.ts +1 -0
  44. package/dist/packages/VouchersRedeemed/components/VoucherRedeemedCard/index.js +4 -0
  45. package/dist/packages/VouchersRedeemed/components/VouchersRedeemedSkeleton/VouchersRedeemedSkeleton.d.ts +15 -0
  46. package/dist/packages/VouchersRedeemed/components/VouchersRedeemedSkeleton/VouchersRedeemedSkeleton.js +49 -0
  47. package/dist/packages/VouchersRedeemed/components/VouchersRedeemedSkeleton/index.d.ts +1 -0
  48. package/dist/packages/VouchersRedeemed/components/VouchersRedeemedSkeleton/index.js +4 -0
  49. package/dist/packages/VouchersRedeemed/data/validVouchers.d.ts +1 -0
  50. package/dist/packages/VouchersRedeemed/data/validVouchers.js +20 -0
  51. package/dist/packages/VouchersRedeemed/utils/getCouponPrice.d.ts +1 -0
  52. package/dist/packages/VouchersRedeemed/utils/getCouponPrice.js +8 -0
  53. package/dist/styles/adaptive-carousel.global.css +1 -0
  54. package/dist/styles/coupons.global.css +1 -1
  55. package/dist/styles/regionalization.global.css +1 -1
  56. package/dist/styles/vouchers-redeemed.global.css +1 -0
  57. package/dist/utils/carousel/carouselProps.d.ts +33 -0
  58. package/dist/utils/carousel/carouselProps.js +59 -0
  59. package/dist/utils/scroll/isScrollToEnd.d.ts +1 -0
  60. package/dist/utils/scroll/isScrollToEnd.js +4 -0
  61. package/dist/utils/setBoldTextParts.d.ts +1 -0
  62. package/dist/utils/setBoldTextParts.js +7 -0
  63. package/package.json +1 -1
  64. package/dist/packages/Coupons/components/Breadcrumb.d.ts +0 -6
  65. package/dist/packages/Coupons/components/Breadcrumb.js +0 -33
  66. package/dist/packages/Coupons/components/Modal.d.ts +0 -8
  67. package/dist/packages/Coupons/components/Modal.js +0 -62
  68. package/dist/packages/Coupons/components/ModalFooter.d.ts +0 -9
  69. package/dist/packages/Coupons/components/ModalFooter.js +0 -25
  70. package/dist/packages/Coupons/components/ModalHeader.d.ts +0 -6
  71. package/dist/packages/Coupons/components/ModalHeader.js +0 -25
  72. package/dist/packages/Coupons/types/Views.d.ts +0 -1
  73. package/dist/packages/Coupons/types/Views.js +0 -1
  74. package/dist/packages/Coupons/views/CouponsView.d.ts +0 -15
  75. package/dist/packages/Coupons/views/CouponsView.js +0 -131
  76. package/dist/packages/Coupons/views/EmptyCartView.d.ts +0 -6
  77. package/dist/packages/Coupons/views/EmptyCartView.js +0 -36
  78. package/dist/packages/Coupons/views/LoadingView.d.ts +0 -7
  79. package/dist/packages/Coupons/views/LoadingView.js +0 -39
  80. package/dist/packages/Coupons/views/OverwriteView.d.ts +0 -14
  81. package/dist/packages/Coupons/views/OverwriteView.js +0 -58
  82. package/dist/packages/Coupons/views/RulesView.d.ts +0 -13
  83. package/dist/packages/Coupons/views/RulesView.js +0 -49
  84. package/dist/packages/Coupons/views/index.d.ts +0 -5
  85. package/dist/packages/Coupons/views/index.js +0 -12
@@ -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,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 {};
@@ -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,33 @@
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
+ isIO?: boolean;
9
+ activeOrderFormCoupon?: string;
10
+ genericTaggingEvent?: (name: string, params: object) => void;
11
+ couponsList?: CouponType[];
12
+ qtdCouponsView?: number;
13
+ getCouponsMutation?: any;
14
+ addCouponMutation?: any;
15
+ removeCouponMutation?: any;
16
+ }
17
+ export interface ChangeCouponParams {
18
+ couponName: string;
19
+ isAdding: boolean;
20
+ isFromForm: boolean;
21
+ }
22
+ export declare function useCoupons({ orderFormId, hasItemsInCart, builder, isIO, activeOrderFormCoupon, genericTaggingEvent, couponsList, qtdCouponsView, getCouponsMutation, addCouponMutation, removeCouponMutation }: UseCouponsParams): {
23
+ isLoadingCouponList: boolean;
24
+ coupons: CouponType[];
25
+ currentCoupon: string;
26
+ isLoadingButton: boolean;
27
+ inputCoupon: string;
28
+ isInputError: boolean;
29
+ showAlert: AlertType;
30
+ handleSubmit: (event: React.FormEvent<HTMLFormElement>) => Promise<void>;
31
+ handleChangeInput: (event: React.ChangeEvent<HTMLInputElement>) => void;
32
+ changeCoupon: ({ couponName, isAdding, isFromForm }: ChangeCouponParams) => Promise<void>;
33
+ };