@plurix/ecom-components 1.14.2-commerce.9 → 1.14.2

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 (32) hide show
  1. package/dist/packages/ChangeOrderModal/ChangeOrderModal.d.ts +12 -1
  2. package/dist/packages/ChangeOrderModal/ChangeOrderModal.js +78 -67
  3. package/dist/packages/ChangeOrderModal/api/getOrderForm.js +6 -15
  4. package/dist/packages/ChangeOrderModal/api/getProductsSimilars.d.ts +7 -4
  5. package/dist/packages/ChangeOrderModal/api/getProductsSimilars.js +22 -21
  6. package/dist/packages/ChangeOrderModal/api/postChangeOrder.d.ts +6 -1
  7. package/dist/packages/ChangeOrderModal/api/postChangeOrder.js +11 -17
  8. package/dist/packages/Coupons/Coupons.d.ts +4 -1
  9. package/dist/packages/Coupons/Coupons.js +67 -57
  10. package/dist/packages/Coupons/api/addCoupon.js +6 -6
  11. package/dist/packages/Coupons/api/getCoupons.js +5 -5
  12. package/dist/packages/Coupons/components/CouponCard.d.ts +3 -1
  13. package/dist/packages/Coupons/components/CouponCard.js +94 -83
  14. package/dist/packages/Coupons/views/CouponsView.d.ts +3 -1
  15. package/dist/packages/Coupons/views/CouponsView.js +87 -78
  16. package/dist/packages/ProductCard/ProductCardBadge/ProductCardBadgeKg.js +13 -10
  17. package/dist/packages/ProductCard/ProductCardBadge/ProductCardDiscountBadge.d.ts +3 -2
  18. package/dist/packages/ProductCard/ProductCardBadge/ProductCardDiscountBadge.js +15 -31
  19. package/dist/packages/ProductCard/ProductCardHorizontal/index.js +31 -30
  20. package/dist/packages/ProductCard/ProductCardPrice/index.d.ts +8 -1
  21. package/dist/packages/ProductCard/ProductCardPrice/index.js +27 -31
  22. package/dist/packages/ProductCard/ProductCardVertical/index.js +16 -15
  23. package/dist/packages/Regionalization/Regionalization.d.ts +1 -1
  24. package/dist/packages/Regionalization/Regionalization.js +15 -13
  25. package/dist/packages/Regionalization/context/RegionalizationContext.d.ts +1 -1
  26. package/dist/packages/Regionalization/context/RegionalizationContext.js +31 -29
  27. package/dist/packages/Regionalization/types/RegionalizationProps.d.ts +1 -0
  28. package/dist/packages/Regionalization/views/AllStoresScreen.js +21 -21
  29. package/dist/styles/regionalization.global.css +1 -1
  30. package/dist/types/ProductCard.d.ts +13 -12
  31. package/dist/utils/changerOrderModal.js +13 -16
  32. package/package.json +1 -1
@@ -1,132 +1,143 @@
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";
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";
5
4
  import { CouponIcon as H } from "../../../assets/svgs/CouponIcon.js";
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,
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,
14
14
  secondCouponName: d,
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
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
26
28
  }) => {
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)
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)
33
35
  try {
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", {
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", {
38
45
  name: "cupom aplicado",
39
- cupomName: a
40
- }), p("success"), r(!0), j && window.location.reload()) : (o == null || o("discount_coupon", {
46
+ cupomName: l
47
+ }), m("success"), u(!0), r && window.location.reload()) : (o == null || o("discount_coupon", {
41
48
  name: "cupom aplicando - cupom incorreto ou expirado",
42
- cupomName: a,
43
- objectError: L.error
44
- }), p("error"), r(!1), t("")), m(!0);
49
+ cupomName: l,
50
+ objectError: V.error
51
+ }), m("error"), u(!1), L("")), f(!0);
45
52
  } else
46
- w(a), y("overwrite-view");
47
- } catch (L) {
53
+ _(l), j("overwrite-view");
54
+ } catch (h) {
48
55
  o == null || o("discount_coupon", {
49
56
  name: "problema na api",
50
- cupomName: a
51
- }), r(!1), p("error"), m(!0);
57
+ cupomName: l
58
+ }), u(!1), m("error"), f(!0);
52
59
  } finally {
53
- h(!1);
60
+ w(!1);
54
61
  }
55
62
  else
56
63
  o == null || o("discount_coupon", {
57
64
  name: "Modal de cart vazio acionado"
58
- }), A(!0);
59
- }, M = async () => {
60
- if (D)
65
+ }), k(!0);
66
+ }, $ = async () => {
67
+ if (R)
61
68
  try {
62
- h(!0), k(!1);
63
- const a = await G(_, x);
64
- a.error.length <= 0 ? (o == null || o("discount_coupon", {
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", {
65
76
  name: "cupom removido com sucesso",
66
- cupomName: c
67
- }), p("removed"), r(!1), t(""), w(""), j && window.location.reload()) : (o == null || o("discount_coupon", {
77
+ cupomName: s
78
+ }), m("removed"), u(!1), L(""), _(""), r && window.location.reload()) : (o == null || o("discount_coupon", {
68
79
  name: "algum problema na remoção do cupom",
69
- cupomName: c,
70
- objectError: a.error
71
- }), p("error"), r(!0)), m(!0);
72
- } catch (a) {
80
+ cupomName: s,
81
+ objectError: h.error
82
+ }), m("error"), u(!0)), f(!0);
83
+ } catch (l) {
73
84
  o == null || o("discount_coupon", {
74
85
  name: "problema na api - na remoção do cupom",
75
- cupomName: c
76
- }), p("error"), r(!0), m(!0);
86
+ cupomName: s
87
+ }), m("error"), u(!0), f(!0);
77
88
  } finally {
78
- h(!1);
89
+ w(!1);
79
90
  }
80
91
  else
81
92
  o == null || o("discount_coupon", {
82
93
  name: "Modal de cart vazio acionado"
83
- }), A(!0);
84
- }, $ = () => {
85
- N(!0), i(l), y("rules-view");
94
+ }), k(!0);
95
+ }, q = () => {
96
+ J(!0), S(a), j("rules-view");
86
97
  };
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 })
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 })
92
103
  ] }),
93
- l.couponValue && /* @__PURE__ */ u("p", { className: "price-badge", children: [
104
+ a.couponValue && /* @__PURE__ */ p("p", { className: "price-badge", children: [
94
105
  "- ",
95
- l.couponValue
106
+ a.couponValue
96
107
  ] }),
97
- l.couponDescription && /* @__PURE__ */ s("h4", { className: "subtitle", children: l.couponDescription }),
98
- l.couponExpirationDate && /* @__PURE__ */ u("h4", { className: "subtitle", children: [
108
+ a.couponDescription && /* @__PURE__ */ c("h4", { className: "subtitle", children: a.couponDescription }),
109
+ a.couponExpirationDate && /* @__PURE__ */ p("h4", { className: "subtitle", children: [
99
110
  "Válido até ",
100
- l.couponExpirationDate
111
+ a.couponExpirationDate
101
112
  ] })
102
113
  ] }),
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, {}) }),
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, {}) }),
107
118
  "Aplicado"
108
119
  ] }),
109
- b ? /* @__PURE__ */ s(
120
+ x ? /* @__PURE__ */ c(
110
121
  "button",
111
122
  {
112
- onClick: M,
123
+ onClick: $,
113
124
  className: "remove-coupon",
114
- disabled: R,
125
+ disabled: A,
115
126
  children: "Remover"
116
127
  }
117
- ) : /* @__PURE__ */ s(
128
+ ) : /* @__PURE__ */ c(
118
129
  "button",
119
130
  {
120
- onClick: () => V(l.couponName),
131
+ onClick: () => N(a.couponName),
121
132
  className: "apply-coupon",
122
- disabled: R,
133
+ disabled: A,
123
134
  children: "Aplicar"
124
135
  }
125
136
  ),
126
- l.couponDescription && /* @__PURE__ */ s("a", { onClick: $, children: "Ver Regras" })
137
+ a.couponDescription && /* @__PURE__ */ c("a", { onClick: q, children: "Ver Regras" })
127
138
  ] })
128
139
  ] });
129
140
  };
130
141
  export {
131
- X as CouponCard
142
+ C as CouponCard
132
143
  };
@@ -8,6 +8,8 @@ interface CouponsViewProps extends Omit<CouponCardProps, OmittedProps> {
8
8
  hasItemsInCart: boolean;
9
9
  closeIOModal?: () => void;
10
10
  coupons: CouponType[];
11
+ addCouponMutation?: any;
12
+ removeCouponMutation?: any;
11
13
  }
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;
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;
13
15
  export {};
@@ -1,122 +1,131 @@
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,
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,
13
15
  hasItemsInCart: C,
14
16
  isIO: p,
15
- closeIOModal: u,
16
- coupons: c,
17
+ closeIOModal: s,
18
+ coupons: n,
17
19
  firstCouponName: i,
18
- secondCouponName: _,
19
- replaceCoupon: w,
20
- setView: A,
21
- setActiveRule: D,
22
- setDataItem: L,
20
+ secondCouponName: L,
21
+ replaceCoupon: A,
22
+ setView: B,
23
+ setActiveRule: q,
24
+ setDataItem: H,
23
25
  setFirstCouponName: m,
24
- setSecondCouponName: n,
25
- setReplaceCoupon: B,
26
- setIsCloseModalEmpty: S,
27
- genericTaggingEvent: r
26
+ setSecondCouponName: f,
27
+ setReplaceCoupon: N,
28
+ setIsCloseModalEmpty: J,
29
+ genericTaggingEvent: t
28
30
  }) => {
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();
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();
33
35
  try {
34
- if (!i || i && w) {
36
+ if (!i || i && A) {
35
37
  j(!0);
36
- const y = await G(b, x, t);
37
- B(!1), n(""), y.error.length <= 0 ? (r == null || r("discount_coupon", {
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", {
38
45
  name: "Cupom aplicado do input",
39
- couponName: t
40
- }), s("success"), h(!0), m(t), p && window.location.reload()) : (r == null || r("discount_coupon", {
46
+ couponName: r
47
+ }), u("success"), y(!0), m(r), p && window.location.reload()) : (t == null || t("discount_coupon", {
41
48
  name: "Cupom do input expirado ou invalido",
42
- couponName: t,
43
- objectError: y.error
44
- }), s("error"), h(!1), m("")), d(!0);
49
+ couponName: r,
50
+ objectError: S.error
51
+ }), u("error"), y(!1), m("")), e(!0);
45
52
  } else
46
- n(t), A("overwrite-view");
47
- } catch (y) {
48
- r == null || r("discount_coupon", {
53
+ f(r), B("overwrite-view");
54
+ } catch (b) {
55
+ t == null || t("discount_coupon", {
49
56
  name: "Cupom do input - error na api",
50
- couponName: t
51
- }), s("error"), h(!1), d(!0);
57
+ couponName: r
58
+ }), u("error"), y(!1), e(!0);
52
59
  } finally {
53
60
  j(!1);
54
61
  }
55
62
  };
56
- return F(() => {
57
- f && setTimeout(() => d(!1), 5e3);
58
- }, [P, f]), /* @__PURE__ */ e(N, { children: [
59
- p && u && /* @__PURE__ */ o(
60
- J,
63
+ return Q(() => {
64
+ h && setTimeout(() => e(!1), 5e3);
65
+ }, [G, h]), /* @__PURE__ */ d(_, { children: [
66
+ p && s && /* @__PURE__ */ o(
67
+ R,
61
68
  {
62
- closeModal: u,
69
+ closeModal: s,
63
70
  title: "Meus Cupons",
64
- genericTaggingEvent: r
71
+ genericTaggingEvent: t
65
72
  }
66
73
  ),
67
- C ? /* @__PURE__ */ o("div", { className: "form-coupons", children: /* @__PURE__ */ e("form", { onSubmit: z, children: [
74
+ C ? /* @__PURE__ */ o("div", { className: "form-coupons", children: /* @__PURE__ */ d("form", { onSubmit: M, children: [
68
75
  /* @__PURE__ */ o(
69
76
  "input",
70
77
  {
71
78
  type: "text",
72
79
  placeholder: "Insira o cupom",
73
- value: t,
74
- onChange: k
80
+ value: r,
81
+ onChange: K
75
82
  }
76
83
  ),
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, {}) }),
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, {}) }),
80
87
  "Para adicionar um cupom é necessário que você adicione pelo menos 1 produto no carrinho"
81
88
  ] }) }),
82
- /* @__PURE__ */ o("div", { className: "container-title-coupons", children: c.length > 0 ? /* @__PURE__ */ e(N, { children: [
89
+ /* @__PURE__ */ o("div", { className: "container-title-coupons", children: n.length > 0 ? /* @__PURE__ */ d(_, { children: [
83
90
  /* @__PURE__ */ o("h2", { children: "Cupons disponíveis" }),
84
- /* @__PURE__ */ o("div", { className: "container-coupons", children: c.map((l) => /* @__PURE__ */ o(
85
- Q,
91
+ /* @__PURE__ */ o("div", { className: "container-coupons", children: n.map((a) => /* @__PURE__ */ o(
92
+ V,
86
93
  {
87
- account: b,
88
- orderFormId: x,
94
+ removeCouponMutation: D,
95
+ addCouponMutation: w,
96
+ account: x,
97
+ orderFormId: c,
89
98
  hasItemsInCart: C,
90
99
  isIO: p,
91
- item: l,
100
+ item: a,
92
101
  firstCouponName: i,
93
- secondCouponName: _,
94
- replaceCoupon: w,
95
- setView: A,
102
+ secondCouponName: L,
103
+ replaceCoupon: A,
104
+ setView: B,
96
105
  setFirstCouponName: m,
97
- setSecondCouponName: n,
98
- setActiveRule: D,
99
- setDataItem: L,
100
- setReplaceCoupon: B,
101
- setAlert: d,
102
- setType: s,
103
- setIsCloseModalEmpty: S,
104
- genericTaggingEvent: r
106
+ setSecondCouponName: f,
107
+ setActiveRule: q,
108
+ setDataItem: H,
109
+ setReplaceCoupon: N,
110
+ setAlert: e,
111
+ setType: u,
112
+ setIsCloseModalEmpty: J,
113
+ genericTaggingEvent: t
105
114
  },
106
- l.couponName
115
+ a.couponName
107
116
  )) })
108
- ] }) : /* @__PURE__ */ o(U, {}) }),
109
- f && /* @__PURE__ */ o(V, { type: M }),
110
- p && u && /* @__PURE__ */ o(
111
- K,
117
+ ] }) : /* @__PURE__ */ o(W, {}) }),
118
+ h && /* @__PURE__ */ o(X, { type: z }),
119
+ p && s && /* @__PURE__ */ o(
120
+ U,
112
121
  {
113
- isFloating: c.length > 0,
114
- cancelButtonAction: u,
122
+ isFloating: n.length > 0,
123
+ cancelButtonAction: s,
115
124
  cancelButtonText: "Sair"
116
125
  }
117
126
  )
118
127
  ] });
119
128
  };
120
129
  export {
121
- E as CouponsView
130
+ to as CouponsView
122
131
  };
@@ -1,15 +1,18 @@
1
- import { jsx as a, jsxs as c } from "react/jsx-runtime";
2
- const g = ({
3
- measurementUnit: e,
4
- setIsShowProductBadge: d,
5
- unitMultiplier: r
6
- }) => e === "un" ? null : r < 1 ? (d(!0), /* @__PURE__ */ a("div", { className: "product-card-badge", children: /* @__PURE__ */ c("p", { className: "product-card-badge-kg", children: [
7
- r * 1e3,
1
+ import { jsx as a, jsxs as g } from "react/jsx-runtime";
2
+ import { useEffect as o } from "react";
3
+ const f = ({
4
+ measurementUnit: c,
5
+ setIsShowProductBadge: r,
6
+ unitMultiplier: d
7
+ }) => (o(() => {
8
+ c !== "un" && (d < 1 || d >= 1) && r(!0);
9
+ }, [c, d, r]), c === "un" ? null : d < 1 ? /* @__PURE__ */ a("div", { className: "product-card-badge", children: /* @__PURE__ */ g("p", { className: "product-card-badge-kg", children: [
10
+ d * 1e3,
8
11
  "g"
9
- ] }) })) : (r >= 1 && d(!0), /* @__PURE__ */ a("div", { className: "product-card-badge", children: /* @__PURE__ */ c("p", { className: "product-card-badge-kg", children: [
10
- r,
12
+ ] }) }) : /* @__PURE__ */ a("div", { className: "product-card-badge", children: /* @__PURE__ */ g("p", { className: "product-card-badge-kg", children: [
13
+ d,
11
14
  "kg"
12
15
  ] }) }));
13
16
  export {
14
- g as ProductCardBadgeKg
17
+ f as ProductCardBadgeKg
15
18
  };
@@ -1,4 +1,4 @@
1
- import { SkuSpecificationsProps, ProductCardProps } from '../../../types/ProductCard';
1
+ import { SkuSpecificationsProps, ProductCardProps, offers } from '../../../types/ProductCard';
2
2
 
3
3
  interface ProductCardDiscountBadge {
4
4
  skuSpecifications: SkuSpecificationsProps[];
@@ -8,6 +8,7 @@ interface ProductCardDiscountBadge {
8
8
  hasPromotionalPrice: ProductCardProps['hasPromotionalPrice'];
9
9
  defaultScListPrice?: number;
10
10
  setIsShowProductBadge: React.Dispatch<React.SetStateAction<boolean>>;
11
+ offers: offers;
11
12
  }
12
- export declare const ProductCardDiscountBadge: ({ nativeListPrice, nativeSpotPrice, skuSpecifications, unitMultiplier, hasPromotionalPrice, defaultScListPrice, setIsShowProductBadge }: ProductCardDiscountBadge) => import("react/jsx-runtime").JSX.Element | null;
13
+ export declare const ProductCardDiscountBadge: ({ offers, setIsShowProductBadge }: ProductCardDiscountBadge) => import("react/jsx-runtime").JSX.Element | null;
13
14
  export {};
@@ -1,42 +1,26 @@
1
- import { jsx as b, jsxs as x } from "react/jsx-runtime";
2
- import { useMemo as l, useEffect as D } from "react";
3
- const E = ({
4
- nativeListPrice: c,
5
- nativeSpotPrice: s,
6
- skuSpecifications: n,
7
- unitMultiplier: a,
8
- hasPromotionalPrice: i,
9
- defaultScListPrice: P,
10
- setIsShowProductBadge: d
1
+ import { jsx as d, jsxs as i } from "react/jsx-runtime";
2
+ import { useEffect as a, useMemo as m } from "react";
3
+ const h = ({
4
+ offers: n,
5
+ setIsShowProductBadge: c
11
6
  }) => {
12
- const { listPrice: u, spotPrice: o } = i || {}, f = (r, e) => l(() => {
13
- const g = (r - e) * 100 / r;
14
- return Math.round(g);
15
- }, [e, r]), { listPriceCustom: m, spotPriceCustom: p } = l(() => u && o && o !== s ? {
16
- listPriceCustom: u,
17
- spotPriceCustom: o
18
- } : {
19
- listPriceCustom: c,
20
- spotPriceCustom: s
21
- }, [
22
- u,
23
- o,
24
- s,
25
- c
26
- ]), C = "Venda por unidade", N = n == null ? void 0 : n.some((r) => r.field.originalName === C && r.values.some((e) => e.originalName === "true")), h = P || (N ? m : ((r) => Number(r.toString().match(/^\d+(?:\.\d{0,2})?/)))(m * a)), t = Math.round(
27
- Number(f(h, p))
7
+ const { listPrice: u, price: o } = n == null ? void 0 : n.offers[0], t = Math.round(
8
+ Number(((r, e) => m(() => {
9
+ const s = (r - e) * 100 / r;
10
+ return Math.round(s);
11
+ }, [e, r]))(u, o))
28
12
  );
29
- return D(() => {
13
+ return a(() => {
30
14
  if (!t || t <= 0) {
31
- d(!1);
15
+ c(!1);
32
16
  return;
33
17
  }
34
- d(!0);
35
- }, [t]), !t || t <= 0 ? null : /* @__PURE__ */ b("div", { className: "product-card-discount-badge", children: /* @__PURE__ */ x("p", { className: "product-card-discount-badge-value", children: [
18
+ c(!0);
19
+ }, [t]), !t || t <= 0 ? null : /* @__PURE__ */ d("div", { className: "product-card-discount-badge", children: /* @__PURE__ */ i("p", { className: "product-card-discount-badge-value", children: [
36
20
  t,
37
21
  "%"
38
22
  ] }) });
39
23
  };
40
24
  export {
41
- E as ProductCardDiscountBadge
25
+ h as ProductCardDiscountBadge
42
26
  };