@plurix/ecom-components 1.14.1-COM-1442.2 → 1.14.1-bugfix-1891.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 (53) hide show
  1. package/dist/node_modules/@faststore/components/dist/esm/atoms/Button/Button.js +45 -0
  2. package/dist/node_modules/@faststore/components/dist/esm/atoms/Loader/Loader.js +34 -0
  3. package/dist/node_modules/@faststore/components/dist/esm/molecules/IconButton/IconButton.js +29 -0
  4. package/dist/packages/Carousel/Carousel.js +1 -1
  5. package/dist/packages/CartClubAlert/CartClubAlert.js +1 -1
  6. package/dist/packages/ChangeOrderModal/ChangeOrderModal.d.ts +1 -12
  7. package/dist/packages/ChangeOrderModal/ChangeOrderModal.js +67 -78
  8. package/dist/packages/ChangeOrderModal/api/getOrderForm.js +15 -6
  9. package/dist/packages/ChangeOrderModal/api/getProductsSimilars.d.ts +4 -7
  10. package/dist/packages/ChangeOrderModal/api/getProductsSimilars.js +21 -22
  11. package/dist/packages/ChangeOrderModal/api/postChangeOrder.d.ts +1 -6
  12. package/dist/packages/ChangeOrderModal/api/postChangeOrder.js +17 -11
  13. package/dist/packages/Coupons/Coupons.d.ts +1 -4
  14. package/dist/packages/Coupons/Coupons.js +57 -67
  15. package/dist/packages/Coupons/components/CouponCard.d.ts +1 -3
  16. package/dist/packages/Coupons/components/CouponCard.js +83 -94
  17. package/dist/packages/Coupons/views/CouponsView.d.ts +1 -3
  18. package/dist/packages/Coupons/views/CouponsView.js +78 -87
  19. package/dist/packages/Coupons/views/LoadingView.js +6 -6
  20. package/dist/packages/Modal/Modal.js +1 -1
  21. package/dist/packages/Onboarding/Onboarding.js +1 -1
  22. package/dist/packages/ProductCard/ProductCardBadge/ProductCardBadgeKg.js +10 -13
  23. package/dist/packages/ProductCard/ProductCardBadge/ProductCardDiscountBadge.d.ts +2 -3
  24. package/dist/packages/ProductCard/ProductCardBadge/ProductCardDiscountBadge.js +31 -15
  25. package/dist/packages/ProductCard/ProductCardButton/AddToCartButton.js +1 -1
  26. package/dist/packages/ProductCard/ProductCardButton/CustomQuantitySelector/index.d.ts +2 -17
  27. package/dist/packages/ProductCard/ProductCardButton/CustomQuantitySelector/index.js +1 -1
  28. package/dist/packages/ProductCard/ProductCardButton/QuantitySelector.js +6 -6
  29. package/dist/packages/ProductCard/ProductCardHorizontal/index.js +30 -31
  30. package/dist/packages/ProductCard/ProductCardPrice/index.d.ts +1 -8
  31. package/dist/packages/ProductCard/ProductCardPrice/index.js +31 -27
  32. package/dist/packages/ProductCard/ProductCardVertical/index.js +15 -16
  33. package/dist/packages/ProductCard/index.js +1 -1
  34. package/dist/packages/ProductCardSeeMore/ProductCardSeeMore.js +1 -1
  35. package/dist/packages/Regionalization/Regionalization.d.ts +1 -1
  36. package/dist/packages/Regionalization/Regionalization.js +13 -15
  37. package/dist/packages/Regionalization/context/RegionalizationContext.d.ts +1 -1
  38. package/dist/packages/Regionalization/context/RegionalizationContext.js +29 -31
  39. package/dist/packages/Regionalization/types/RegionalizationProps.d.ts +0 -1
  40. package/dist/packages/Regionalization/views/AllStoresScreen.js +21 -21
  41. package/dist/packages/Regionalization/views/InitialView.js +26 -24
  42. package/dist/packages/Tour/Tour.js +1 -1
  43. package/dist/styles/product-card.global.css +1 -1
  44. package/dist/styles/regionalization.global.css +1 -1
  45. package/dist/types/ProductCard.d.ts +12 -13
  46. package/dist/utils/changerOrderModal.js +16 -13
  47. package/package.json +71 -69
  48. package/dist/packages/ProductCard/ProductCardButton/CustomQuantitySelector/Button.d.ts +0 -18
  49. package/dist/packages/ProductCard/ProductCardButton/CustomQuantitySelector/Button.js +0 -80
  50. package/dist/packages/ProductCard/ProductCardButton/CustomQuantitySelector/IconButton.d.ts +0 -10
  51. package/dist/packages/ProductCard/ProductCardButton/CustomQuantitySelector/IconButton.js +0 -61
  52. package/dist/packages/ProductCard/ProductCardButton/CustomQuantitySelector/Loader.d.ts +0 -8
  53. package/dist/packages/ProductCard/ProductCardButton/CustomQuantitySelector/Loader.js +0 -44
@@ -1,113 +1,103 @@
1
- import { jsx as t, jsxs as P } from "react/jsx-runtime";
2
- import { useState as e, useEffect as j } 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 eo = ({
10
- orderFormId: A,
11
- hasItemsInCart: f,
12
- builder: l,
13
- account: w,
1
+ import { jsx as t, jsxs as B } from "react/jsx-runtime";
2
+ import { useState as e, useEffect as S } from "react";
3
+ import { getCoupons as E } from "./api/getCoupons.js";
4
+ import { LoadingView as G } from "./views/LoadingView.js";
5
+ import { CouponsView as H } from "./views/CouponsView.js";
6
+ import { RulesView as K } from "./views/RulesView.js";
7
+ import { OverwriteView as P } from "./views/OverwriteView.js";
8
+ import { EmptyCartView as Q } from "./views/EmptyCartView.js";
9
+ /* empty css */const I = ({
10
+ orderFormId: h,
11
+ hasItemsInCart: a,
12
+ builder: j,
13
+ account: f,
14
14
  isIO: o = !1,
15
15
  closeIOModal: r,
16
16
  activeOrderFormCoupon: n,
17
17
  genericTaggingEvent: s,
18
- disableFirstEmptyModal: J,
19
- couponsList: p,
20
- qtdCouponsView: C,
21
- getCouponsMutation: q,
22
- addCouponMutation: D,
23
- removeCouponMutation: L
18
+ disableFirstEmptyModal: A,
19
+ couponsList: l,
20
+ qtdCouponsView: w
24
21
  }) => {
25
- const [k, N] = e(!0), [z, a] = e([]), [u, c] = e("coupons-view"), [B, d] = e(!1), [y, v] = e(!1), [R, V] = e(""), [m, S] = e(""), [E, x] = e(
26
- !J
27
- ), [G, H] = e();
28
- return j(() => {
29
- n && V(n);
30
- }, [n]), j(() => {
22
+ const [L, C] = e(!0), [q, p] = e([]), [u, c] = e("coupons-view"), [D, y] = e(!1), [N, d] = e(!1), [v, R] = e(""), [m, V] = e(""), [J, x] = e(
23
+ !A
24
+ ), [b, k] = e();
25
+ return S(() => {
26
+ n && R(n);
27
+ }, [n]), S(() => {
31
28
  (async () => {
32
- N(!0);
29
+ C(!0);
33
30
  try {
34
- const i = o ? await Z(w, l, p) : await q({
35
- input: {
36
- builder: l,
37
- couponsList: p
38
- }
39
- }), h = o ? i : JSON.parse(i.getCoupons.data).coupons;
40
- if (C) {
41
- const K = h.slice(0, C);
42
- a(K);
31
+ const i = await E(f, j, l);
32
+ if (w) {
33
+ const z = i.slice(0, w);
34
+ p(z);
43
35
  return;
44
36
  }
45
- a(h);
37
+ p(i);
46
38
  return;
47
39
  } catch (i) {
48
- a([]);
40
+ p([]);
49
41
  } finally {
50
- N(!1);
42
+ C(!1);
51
43
  }
52
44
  })();
53
- }, [JSON.stringify(p)]), k ? /* @__PURE__ */ t("div", { className: "coupons-container", children: /* @__PURE__ */ t(
54
- Q,
45
+ }, [JSON.stringify(l)]), L ? /* @__PURE__ */ t("div", { className: "coupons-container", children: /* @__PURE__ */ t(
46
+ G,
55
47
  {
56
48
  isIO: o,
57
49
  closeIOModal: r,
58
50
  genericTaggingEvent: s
59
51
  }
60
- ) }) : /* @__PURE__ */ P("div", { className: "coupons-container", children: [
52
+ ) }) : /* @__PURE__ */ B("div", { className: "coupons-container", children: [
61
53
  (!o || o && u === "coupons-view") && /* @__PURE__ */ t(
62
- U,
54
+ H,
63
55
  {
64
- removeCouponMutation: L,
65
- addCouponMutation: D,
66
- orderFormId: A,
67
- hasItemsInCart: f,
68
- account: w,
56
+ orderFormId: h,
57
+ hasItemsInCart: a,
58
+ account: f,
69
59
  isIO: o,
70
60
  closeIOModal: r,
71
- coupons: z,
72
- firstCouponName: R,
61
+ coupons: q,
62
+ firstCouponName: v,
73
63
  secondCouponName: m,
74
- replaceCoupon: y,
64
+ replaceCoupon: N,
75
65
  setView: c,
76
- setFirstCouponName: V,
77
- setSecondCouponName: S,
78
- setActiveRule: d,
79
- setDataItem: H,
80
- setReplaceCoupon: v,
66
+ setFirstCouponName: R,
67
+ setSecondCouponName: V,
68
+ setActiveRule: y,
69
+ setDataItem: k,
70
+ setReplaceCoupon: d,
81
71
  setIsCloseModalEmpty: x,
82
72
  genericTaggingEvent: s
83
73
  }
84
74
  ),
85
- (!o || o && u === "rules-view") && B && /* @__PURE__ */ t(
86
- W,
75
+ (!o || o && u === "rules-view") && D && /* @__PURE__ */ t(
76
+ K,
87
77
  {
88
- dataItem: G,
89
- setActiveRule: d,
78
+ dataItem: b,
79
+ setActiveRule: y,
90
80
  setView: c,
91
81
  isIO: o,
92
82
  closeIOModal: r,
93
83
  genericTaggingEvent: s
94
84
  }
95
85
  ),
96
- (!o || o && u === "overwrite-view") && m && !y && /* @__PURE__ */ t(
97
- X,
86
+ (!o || o && u === "overwrite-view") && m && !N && /* @__PURE__ */ t(
87
+ P,
98
88
  {
99
- firstCouponName: R,
89
+ firstCouponName: v,
100
90
  secondCouponName: m,
101
91
  setView: c,
102
- setReplaceCoupon: v,
103
- setSecondCouponName: S,
92
+ setReplaceCoupon: d,
93
+ setSecondCouponName: V,
104
94
  isIO: o,
105
95
  closeIOModal: r,
106
96
  genericTaggingEvent: s
107
97
  }
108
98
  ),
109
- !f && E && /* @__PURE__ */ t(
110
- Y,
99
+ !a && J && /* @__PURE__ */ t(
100
+ Q,
111
101
  {
112
102
  setIsCloseModalEmpty: x,
113
103
  genericTaggingEvent: s
@@ -116,5 +106,5 @@ import { getCoupons as Z } from "./api/getCoupons.js";
116
106
  ] });
117
107
  };
118
108
  export {
119
- eo as Coupons
109
+ I as Coupons
120
110
  };
@@ -21,7 +21,5 @@ export interface CouponCardProps {
21
21
  setType: (type: AlertType) => void;
22
22
  setIsCloseModalEmpty: (isCloseModalEmpty: boolean) => void;
23
23
  genericTaggingEvent?: (name: string, params: object) => void;
24
- addCouponMutation?: any;
25
- removeCouponMutation?: any;
26
24
  }
27
- export declare const CouponCard: ({ account, 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;
25
+ export declare const CouponCard: ({ account, orderFormId, hasItemsInCart, isIO, item, firstCouponName, secondCouponName, replaceCoupon, setView, setActiveRule, setDataItem, setFirstCouponName, setSecondCouponName, setReplaceCoupon, setAlert, setType, setIsCloseModalEmpty, genericTaggingEvent }: CouponCardProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,143 +1,132 @@
1
- import { jsxs as p, jsx as c } from "react/jsx-runtime";
2
- import { useState as z, useEffect as B } from "react";
3
- import { addCoupon as G } from "../api/addCoupon.js";
1
+ import { jsxs as u, jsx as s } from "react/jsx-runtime";
2
+ import { useState as z, useEffect as q } from "react";
3
+ import { addCoupon as B } from "../api/addCoupon.js";
4
+ import { removeCoupon as G } from "../api/removeCoupon.js";
4
5
  import { CouponIcon as H } from "../../../assets/svgs/CouponIcon.js";
5
- import { SuccessIcon as K } from "../../../assets/svgs/SuccessIcon.js";
6
- import { removeCoupon as P } from "../api/removeCoupon.js";
7
- const C = ({
8
- account: D,
9
- orderFormId: t,
10
- hasItemsInCart: R,
11
- isIO: r = !1,
12
- item: a,
13
- firstCouponName: s,
6
+ import { SuccessIcon as J } from "../../../assets/svgs/SuccessIcon.js";
7
+ const X = ({
8
+ account: _,
9
+ orderFormId: x,
10
+ hasItemsInCart: D,
11
+ isIO: j = !1,
12
+ item: l,
13
+ firstCouponName: c,
14
14
  secondCouponName: d,
15
- replaceCoupon: b,
16
- setView: j,
17
- setActiveRule: J,
18
- setDataItem: S,
19
- setFirstCouponName: L,
20
- setSecondCouponName: _,
21
- setReplaceCoupon: y,
22
- setAlert: f,
23
- setType: m,
24
- setIsCloseModalEmpty: k,
25
- genericTaggingEvent: o,
26
- addCouponMutation: i,
27
- removeCouponMutation: M
15
+ replaceCoupon: f,
16
+ setView: y,
17
+ setActiveRule: N,
18
+ setDataItem: i,
19
+ setFirstCouponName: t,
20
+ setSecondCouponName: w,
21
+ setReplaceCoupon: k,
22
+ setAlert: m,
23
+ setType: p,
24
+ setIsCloseModalEmpty: A,
25
+ genericTaggingEvent: o
28
26
  }) => {
29
- const [x, u] = z(!1), [A, w] = z(!1);
30
- B(() => {
31
- d.toLowerCase() !== a.couponName.toLowerCase() && u(!1), s && !d && s.toLowerCase() === a.couponName.toLowerCase() && u(!0), s && d && b && d.toLowerCase() === a.couponName.toLowerCase() && N(d);
32
- }, [s, d, b]);
33
- const N = async (l) => {
34
- if (R)
27
+ const [b, r] = z(!1), [R, h] = z(!1);
28
+ q(() => {
29
+ d.toLowerCase() !== l.couponName.toLowerCase() && r(!1), c && !d && c.toLowerCase() === l.couponName.toLowerCase() && r(!0), c && d && f && d.toLowerCase() === l.couponName.toLowerCase() && V(d);
30
+ }, [c, d, f]);
31
+ const V = async (a) => {
32
+ if (D)
35
33
  try {
36
- if (!s || s && b) {
37
- w(!0);
38
- const h = r ? await G(D, t, l) : await i({
39
- input: {
40
- orderFormId: t,
41
- couponId: l
42
- }
43
- }), V = r ? h : JSON.parse(h.addCoupon.data);
44
- y(!1), L(l), _(""), V.error.length <= 0 ? (o == null || o("discount_coupon", {
34
+ if (!c || c && f) {
35
+ h(!0);
36
+ const L = await B(_, x, a);
37
+ k(!1), t(a), w(""), L.error.length <= 0 ? (o == null || o("discount_coupon", {
45
38
  name: "cupom aplicado",
46
- cupomName: l
47
- }), m("success"), u(!0), r && window.location.reload()) : (o == null || o("discount_coupon", {
39
+ cupomName: a
40
+ }), p("success"), r(!0), j && window.location.reload()) : (o == null || o("discount_coupon", {
48
41
  name: "cupom aplicando - cupom incorreto ou expirado",
49
- cupomName: l,
50
- objectError: V.error
51
- }), m("error"), u(!1), L("")), f(!0);
42
+ cupomName: a,
43
+ objectError: L.error
44
+ }), p("error"), r(!1), t("")), m(!0);
52
45
  } else
53
- _(l), j("overwrite-view");
54
- } catch (h) {
46
+ w(a), y("overwrite-view");
47
+ } catch (L) {
55
48
  o == null || o("discount_coupon", {
56
49
  name: "problema na api",
57
- cupomName: l
58
- }), u(!1), m("error"), f(!0);
50
+ cupomName: a
51
+ }), r(!1), p("error"), m(!0);
59
52
  } finally {
60
- w(!1);
53
+ h(!1);
61
54
  }
62
55
  else
63
56
  o == null || o("discount_coupon", {
64
57
  name: "Modal de cart vazio acionado"
65
- }), k(!0);
66
- }, $ = async () => {
67
- if (R)
58
+ }), A(!0);
59
+ }, M = async () => {
60
+ if (D)
68
61
  try {
69
- w(!0), y(!1);
70
- const l = r ? await P(D, t) : await M({
71
- input: {
72
- orderFormId: t
73
- }
74
- }), h = r ? l : JSON.parse(l.removeCoupon.data);
75
- h.error.length <= 0 ? (o == null || o("discount_coupon", {
62
+ h(!0), k(!1);
63
+ const a = await G(_, x);
64
+ a.error.length <= 0 ? (o == null || o("discount_coupon", {
76
65
  name: "cupom removido com sucesso",
77
- cupomName: s
78
- }), m("removed"), u(!1), L(""), _(""), r && window.location.reload()) : (o == null || o("discount_coupon", {
66
+ cupomName: c
67
+ }), p("removed"), r(!1), t(""), w(""), j && window.location.reload()) : (o == null || o("discount_coupon", {
79
68
  name: "algum problema na remoção do cupom",
80
- cupomName: s,
81
- objectError: h.error
82
- }), m("error"), u(!0)), f(!0);
83
- } catch (l) {
69
+ cupomName: c,
70
+ objectError: a.error
71
+ }), p("error"), r(!0)), m(!0);
72
+ } catch (a) {
84
73
  o == null || o("discount_coupon", {
85
74
  name: "problema na api - na remoção do cupom",
86
- cupomName: s
87
- }), m("error"), u(!0), f(!0);
75
+ cupomName: c
76
+ }), p("error"), r(!0), m(!0);
88
77
  } finally {
89
- w(!1);
78
+ h(!1);
90
79
  }
91
80
  else
92
81
  o == null || o("discount_coupon", {
93
82
  name: "Modal de cart vazio acionado"
94
- }), k(!0);
95
- }, q = () => {
96
- J(!0), S(a), j("rules-view");
83
+ }), A(!0);
84
+ }, $ = () => {
85
+ N(!0), i(l), y("rules-view");
97
86
  };
98
- return /* @__PURE__ */ p("div", { className: `container-card-coupon ${x ? "active" : ""}`, children: [
99
- /* @__PURE__ */ p("div", { className: "text-container", children: [
100
- /* @__PURE__ */ p("div", { className: "container-title", children: [
101
- /* @__PURE__ */ c(H, { width: 20, height: 16 }),
102
- /* @__PURE__ */ c("h3", { className: "title", children: a.couponName })
87
+ return /* @__PURE__ */ u("div", { className: `container-card-coupon ${b ? "active" : ""}`, children: [
88
+ /* @__PURE__ */ u("div", { className: "text-container", children: [
89
+ /* @__PURE__ */ u("div", { className: "container-title", children: [
90
+ /* @__PURE__ */ s(H, { width: 20, height: 16 }),
91
+ /* @__PURE__ */ s("h3", { className: "title", children: l.couponName })
103
92
  ] }),
104
- a.couponValue && /* @__PURE__ */ p("p", { className: "price-badge", children: [
93
+ l.couponValue && /* @__PURE__ */ u("p", { className: "price-badge", children: [
105
94
  "- ",
106
- a.couponValue
95
+ l.couponValue
107
96
  ] }),
108
- a.couponDescription && /* @__PURE__ */ c("h4", { className: "subtitle", children: a.couponDescription }),
109
- a.couponExpirationDate && /* @__PURE__ */ p("h4", { className: "subtitle", children: [
97
+ l.couponDescription && /* @__PURE__ */ s("h4", { className: "subtitle", children: l.couponDescription }),
98
+ l.couponExpirationDate && /* @__PURE__ */ u("h4", { className: "subtitle", children: [
110
99
  "Válido até ",
111
- a.couponExpirationDate
100
+ l.couponExpirationDate
112
101
  ] })
113
102
  ] }),
114
- /* @__PURE__ */ c("div", { className: "vertical-line" }),
115
- /* @__PURE__ */ p("div", { className: "buttons-container", children: [
116
- x && /* @__PURE__ */ p("button", { className: "applied-coupon", children: [
117
- /* @__PURE__ */ c("span", { className: "applied-coupon-span", children: /* @__PURE__ */ c(K, {}) }),
103
+ /* @__PURE__ */ s("div", { className: "vertical-line" }),
104
+ /* @__PURE__ */ u("div", { className: "buttons-container", children: [
105
+ b && /* @__PURE__ */ u("button", { className: "applied-coupon", children: [
106
+ /* @__PURE__ */ s("span", { className: "applied-coupon-span", children: /* @__PURE__ */ s(J, {}) }),
118
107
  "Aplicado"
119
108
  ] }),
120
- x ? /* @__PURE__ */ c(
109
+ b ? /* @__PURE__ */ s(
121
110
  "button",
122
111
  {
123
- onClick: $,
112
+ onClick: M,
124
113
  className: "remove-coupon",
125
- disabled: A,
114
+ disabled: R,
126
115
  children: "Remover"
127
116
  }
128
- ) : /* @__PURE__ */ c(
117
+ ) : /* @__PURE__ */ s(
129
118
  "button",
130
119
  {
131
- onClick: () => N(a.couponName),
120
+ onClick: () => V(l.couponName),
132
121
  className: "apply-coupon",
133
- disabled: A,
122
+ disabled: R,
134
123
  children: "Aplicar"
135
124
  }
136
125
  ),
137
- a.couponDescription && /* @__PURE__ */ c("a", { onClick: q, children: "Ver Regras" })
126
+ l.couponDescription && /* @__PURE__ */ s("a", { onClick: $, children: "Ver Regras" })
138
127
  ] })
139
128
  ] });
140
129
  };
141
130
  export {
142
- C as CouponCard
131
+ X as CouponCard
143
132
  };
@@ -8,8 +8,6 @@ interface CouponsViewProps extends Omit<CouponCardProps, OmittedProps> {
8
8
  hasItemsInCart: boolean;
9
9
  closeIOModal?: () => void;
10
10
  coupons: CouponType[];
11
- addCouponMutation?: any;
12
- removeCouponMutation?: any;
13
11
  }
14
- export declare const CouponsView: ({ addCouponMutation, removeCouponMutation, account, orderFormId, hasItemsInCart, isIO, closeIOModal, coupons, firstCouponName, secondCouponName, replaceCoupon, setView, setActiveRule, setDataItem, setFirstCouponName, setSecondCouponName, setReplaceCoupon, setIsCloseModalEmpty, genericTaggingEvent }: CouponsViewProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const CouponsView: ({ account, orderFormId, hasItemsInCart, isIO, closeIOModal, coupons, firstCouponName, secondCouponName, replaceCoupon, setView, setActiveRule, setDataItem, setFirstCouponName, setSecondCouponName, setReplaceCoupon, setIsCloseModalEmpty, genericTaggingEvent }: CouponsViewProps) => import("react/jsx-runtime").JSX.Element;
15
13
  export {};
@@ -1,131 +1,122 @@
1
- import { jsxs as d, Fragment as _, jsx as o } from "react/jsx-runtime";
2
- import { useState as l, useEffect as Q } from "react";
3
- import { ModalHeader as R } from "../components/ModalHeader.js";
4
- import { ModalFooter as U } from "../components/ModalFooter.js";
5
- import { CouponCard as V } from "../components/CouponCard.js";
6
- import { NoCoupons as W } from "../components/NoCoupons.js";
7
- import { Alert as X } from "../components/Alert.js";
8
- import { InfoIcon as Y } from "../../../assets/svgs/InfoIcon.js";
9
- import { addCoupon as Z } from "../api/addCoupon.js";
10
- const to = ({
11
- addCouponMutation: w,
12
- removeCouponMutation: D,
13
- account: x,
14
- orderFormId: c,
1
+ import { jsxs as e, Fragment as N, jsx as o } from "react/jsx-runtime";
2
+ import { useState as a, useEffect as F } from "react";
3
+ import { addCoupon as G } from "../api/addCoupon.js";
4
+ import { ModalHeader as J } from "../components/ModalHeader.js";
5
+ import { ModalFooter as K } from "../components/ModalFooter.js";
6
+ import { CouponCard as Q } from "../components/CouponCard.js";
7
+ import { NoCoupons as U } from "../components/NoCoupons.js";
8
+ import { Alert as V } from "../components/Alert.js";
9
+ import { InfoIcon as W } from "../../../assets/svgs/InfoIcon.js";
10
+ const E = ({
11
+ account: b,
12
+ orderFormId: x,
15
13
  hasItemsInCart: C,
16
14
  isIO: p,
17
- closeIOModal: s,
18
- coupons: n,
15
+ closeIOModal: u,
16
+ coupons: c,
19
17
  firstCouponName: i,
20
- secondCouponName: L,
21
- replaceCoupon: A,
22
- setView: B,
23
- setActiveRule: q,
24
- setDataItem: H,
18
+ secondCouponName: _,
19
+ replaceCoupon: w,
20
+ setView: A,
21
+ setActiveRule: D,
22
+ setDataItem: L,
25
23
  setFirstCouponName: m,
26
- setSecondCouponName: f,
27
- setReplaceCoupon: N,
28
- setIsCloseModalEmpty: J,
29
- genericTaggingEvent: t
24
+ setSecondCouponName: n,
25
+ setReplaceCoupon: B,
26
+ setIsCloseModalEmpty: S,
27
+ genericTaggingEvent: r
30
28
  }) => {
31
- const [r, P] = l(""), [k, j] = l(!1), [z, u] = l(""), [h, e] = l(!1), [G, y] = l(!1), K = (a) => {
32
- a.preventDefault(), P(a.target.value);
33
- }, M = async (a) => {
34
- a.preventDefault();
29
+ const [t, q] = a(""), [H, j] = a(!1), [M, s] = a(""), [f, d] = a(!1), [P, h] = a(!1), k = (l) => {
30
+ l.preventDefault(), q(l.target.value);
31
+ }, z = async (l) => {
32
+ l.preventDefault();
35
33
  try {
36
- if (!i || i && A) {
34
+ if (!i || i && w) {
37
35
  j(!0);
38
- const b = p ? await Z(x, c, r) : await w({
39
- input: {
40
- orderFormId: c,
41
- couponId: r
42
- }
43
- }), S = p ? b : JSON.parse(b.addCoupon.data);
44
- N(!1), f(""), S.error.length <= 0 ? (t == null || t("discount_coupon", {
36
+ const y = await G(b, x, t);
37
+ B(!1), n(""), y.error.length <= 0 ? (r == null || r("discount_coupon", {
45
38
  name: "Cupom aplicado do input",
46
- couponName: r
47
- }), u("success"), y(!0), m(r), p && window.location.reload()) : (t == null || t("discount_coupon", {
39
+ couponName: t
40
+ }), s("success"), h(!0), m(t), p && window.location.reload()) : (r == null || r("discount_coupon", {
48
41
  name: "Cupom do input expirado ou invalido",
49
- couponName: r,
50
- objectError: S.error
51
- }), u("error"), y(!1), m("")), e(!0);
42
+ couponName: t,
43
+ objectError: y.error
44
+ }), s("error"), h(!1), m("")), d(!0);
52
45
  } else
53
- f(r), B("overwrite-view");
54
- } catch (b) {
55
- t == null || t("discount_coupon", {
46
+ n(t), A("overwrite-view");
47
+ } catch (y) {
48
+ r == null || r("discount_coupon", {
56
49
  name: "Cupom do input - error na api",
57
- couponName: r
58
- }), u("error"), y(!1), e(!0);
50
+ couponName: t
51
+ }), s("error"), h(!1), d(!0);
59
52
  } finally {
60
53
  j(!1);
61
54
  }
62
55
  };
63
- return Q(() => {
64
- h && setTimeout(() => e(!1), 5e3);
65
- }, [G, h]), /* @__PURE__ */ d(_, { children: [
66
- p && s && /* @__PURE__ */ o(
67
- R,
56
+ return F(() => {
57
+ f && setTimeout(() => d(!1), 5e3);
58
+ }, [P, f]), /* @__PURE__ */ e(N, { children: [
59
+ p && u && /* @__PURE__ */ o(
60
+ J,
68
61
  {
69
- closeModal: s,
62
+ closeModal: u,
70
63
  title: "Meus Cupons",
71
- genericTaggingEvent: t
64
+ genericTaggingEvent: r
72
65
  }
73
66
  ),
74
- C ? /* @__PURE__ */ o("div", { className: "form-coupons", children: /* @__PURE__ */ d("form", { onSubmit: M, children: [
67
+ C ? /* @__PURE__ */ o("div", { className: "form-coupons", children: /* @__PURE__ */ e("form", { onSubmit: z, children: [
75
68
  /* @__PURE__ */ o(
76
69
  "input",
77
70
  {
78
71
  type: "text",
79
72
  placeholder: "Insira o cupom",
80
- value: r,
81
- onChange: K
73
+ value: t,
74
+ onChange: k
82
75
  }
83
76
  ),
84
- /* @__PURE__ */ o("button", { type: "submit", name: "adicionar", disabled: k, children: "Adicionar" })
85
- ] }) }) : /* @__PURE__ */ o("div", { className: "cart-empty-coupons-label", children: /* @__PURE__ */ d("p", { children: [
86
- /* @__PURE__ */ o("span", { children: /* @__PURE__ */ o(Y, {}) }),
77
+ /* @__PURE__ */ o("button", { type: "submit", name: "adicionar", disabled: H, children: "Adicionar" })
78
+ ] }) }) : /* @__PURE__ */ o("div", { className: "cart-empty-coupons-label", children: /* @__PURE__ */ e("p", { children: [
79
+ /* @__PURE__ */ o("span", { children: /* @__PURE__ */ o(W, {}) }),
87
80
  "Para adicionar um cupom é necessário que você adicione pelo menos 1 produto no carrinho"
88
81
  ] }) }),
89
- /* @__PURE__ */ o("div", { className: "container-title-coupons", children: n.length > 0 ? /* @__PURE__ */ d(_, { children: [
82
+ /* @__PURE__ */ o("div", { className: "container-title-coupons", children: c.length > 0 ? /* @__PURE__ */ e(N, { children: [
90
83
  /* @__PURE__ */ o("h2", { children: "Cupons disponíveis" }),
91
- /* @__PURE__ */ o("div", { className: "container-coupons", children: n.map((a) => /* @__PURE__ */ o(
92
- V,
84
+ /* @__PURE__ */ o("div", { className: "container-coupons", children: c.map((l) => /* @__PURE__ */ o(
85
+ Q,
93
86
  {
94
- removeCouponMutation: D,
95
- addCouponMutation: w,
96
- account: x,
97
- orderFormId: c,
87
+ account: b,
88
+ orderFormId: x,
98
89
  hasItemsInCart: C,
99
90
  isIO: p,
100
- item: a,
91
+ item: l,
101
92
  firstCouponName: i,
102
- secondCouponName: L,
103
- replaceCoupon: A,
104
- setView: B,
93
+ secondCouponName: _,
94
+ replaceCoupon: w,
95
+ setView: A,
105
96
  setFirstCouponName: m,
106
- setSecondCouponName: f,
107
- setActiveRule: q,
108
- setDataItem: H,
109
- setReplaceCoupon: N,
110
- setAlert: e,
111
- setType: u,
112
- setIsCloseModalEmpty: J,
113
- genericTaggingEvent: t
97
+ setSecondCouponName: n,
98
+ setActiveRule: D,
99
+ setDataItem: L,
100
+ setReplaceCoupon: B,
101
+ setAlert: d,
102
+ setType: s,
103
+ setIsCloseModalEmpty: S,
104
+ genericTaggingEvent: r
114
105
  },
115
- a.couponName
106
+ l.couponName
116
107
  )) })
117
- ] }) : /* @__PURE__ */ o(W, {}) }),
118
- h && /* @__PURE__ */ o(X, { type: z }),
119
- p && s && /* @__PURE__ */ o(
120
- U,
108
+ ] }) : /* @__PURE__ */ o(U, {}) }),
109
+ f && /* @__PURE__ */ o(V, { type: M }),
110
+ p && u && /* @__PURE__ */ o(
111
+ K,
121
112
  {
122
- isFloating: n.length > 0,
123
- cancelButtonAction: s,
113
+ isFloating: c.length > 0,
114
+ cancelButtonAction: u,
124
115
  cancelButtonText: "Sair"
125
116
  }
126
117
  )
127
118
  ] });
128
119
  };
129
120
  export {
130
- to as CouponsView
121
+ E as CouponsView
131
122
  };