@plurix/ecom-components 1.7.0-loyalty.0 → 1.8.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.
@@ -11,6 +11,7 @@ interface CouponsProps {
11
11
  genericTaggingEvent?: (name: string, params: object) => void;
12
12
  disableFirstEmptyModal?: boolean;
13
13
  couponsList?: CouponType[];
14
+ qtdCouponsView?: number;
14
15
  }
15
- export declare const Coupons: ({ orderFormId, hasItemsInCart, builder, account, isIO, closeIOModal, activeOrderFormCoupon, genericTaggingEvent, disableFirstEmptyModal, couponsList }: CouponsProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const Coupons: ({ orderFormId, hasItemsInCart, builder, account, isIO, closeIOModal, activeOrderFormCoupon, genericTaggingEvent, disableFirstEmptyModal, couponsList, qtdCouponsView }: CouponsProps) => import("react/jsx-runtime").JSX.Element;
16
17
  export {};
@@ -1,103 +1,110 @@
1
- import { jsx as t, jsxs as k } from "react/jsx-runtime";
2
- import { useState as e, useEffect as R } from "react";
3
- import { getCoupons as z } from "./api/getCoupons.js";
4
- import { LoadingView as B } from "./views/LoadingView.js";
5
- import { CouponsView as E } from "./views/CouponsView.js";
6
- import { RulesView as G } from "./views/RulesView.js";
7
- import { OverwriteView as H } from "./views/OverwriteView.js";
8
- import { EmptyCartView as K } from "./views/EmptyCartView.js";
9
- /* empty css */const M = ({
10
- orderFormId: x,
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
11
  hasItemsInCart: i,
12
- builder: S,
12
+ builder: j,
13
13
  account: a,
14
14
  isIO: o = !1,
15
15
  closeIOModal: r,
16
- activeOrderFormCoupon: p,
16
+ activeOrderFormCoupon: n,
17
17
  genericTaggingEvent: s,
18
- disableFirstEmptyModal: h,
19
- couponsList: c
18
+ disableFirstEmptyModal: A,
19
+ couponsList: f,
20
+ qtdCouponsView: l
20
21
  }) => {
21
- const [j, f] = e(!0), [q, l] = e([]), [n, m] = e("coupons-view"), [L, w] = e(!1), [C, d] = e(!1), [y, N] = e(""), [u, V] = e(""), [A, v] = e(
22
- !h
23
- ), [D, J] = e();
24
- return R(() => {
25
- p && N(p);
26
- }, [p]), R(() => {
22
+ const [L, w] = e(!0), [q, p] = e([]), [u, c] = e("coupons-view"), [D, C] = e(!1), [y, N] = e(!1), [d, v] = e(""), [m, R] = e(""), [J, V] = e(
23
+ !A
24
+ ), [b, k] = e();
25
+ return S(() => {
26
+ n && v(n);
27
+ }, [n]), S(() => {
27
28
  (async () => {
28
- f(!0);
29
+ w(!0);
29
30
  try {
30
- const b = await z(a, S, c);
31
- l(b);
31
+ const x = await E(a, j, f);
32
+ if (l) {
33
+ const z = x.slice(0, l);
34
+ p(z);
35
+ return;
36
+ }
37
+ p(x);
38
+ return;
32
39
  } catch {
33
- l([]);
40
+ p([]);
34
41
  } finally {
35
- f(!1);
42
+ w(!1);
36
43
  }
37
44
  })();
38
- }, [JSON.stringify(c)]), j ? /* @__PURE__ */ t("div", { className: "coupons-container", children: /* @__PURE__ */ t(
39
- B,
45
+ }, [JSON.stringify(f)]), L ? /* @__PURE__ */ t("div", { className: "coupons-container", children: /* @__PURE__ */ t(
46
+ G,
40
47
  {
41
48
  isIO: o,
42
49
  closeIOModal: r,
43
50
  genericTaggingEvent: s
44
51
  }
45
- ) }) : /* @__PURE__ */ k("div", { className: "coupons-container", children: [
46
- (!o || o && n === "coupons-view") && /* @__PURE__ */ t(
47
- E,
52
+ ) }) : /* @__PURE__ */ B("div", { className: "coupons-container", children: [
53
+ (!o || o && u === "coupons-view") && /* @__PURE__ */ t(
54
+ H,
48
55
  {
49
- orderFormId: x,
56
+ orderFormId: h,
50
57
  hasItemsInCart: i,
51
58
  account: a,
52
59
  isIO: o,
53
60
  closeIOModal: r,
54
61
  coupons: q,
55
- firstCouponName: y,
56
- secondCouponName: u,
57
- replaceCoupon: C,
58
- setView: m,
59
- setFirstCouponName: N,
60
- setSecondCouponName: V,
61
- setActiveRule: w,
62
- setDataItem: J,
63
- setReplaceCoupon: d,
64
- setIsCloseModalEmpty: v,
62
+ firstCouponName: d,
63
+ secondCouponName: m,
64
+ replaceCoupon: y,
65
+ setView: c,
66
+ setFirstCouponName: v,
67
+ setSecondCouponName: R,
68
+ setActiveRule: C,
69
+ setDataItem: k,
70
+ setReplaceCoupon: N,
71
+ setIsCloseModalEmpty: V,
65
72
  genericTaggingEvent: s
66
73
  }
67
74
  ),
68
- (!o || o && n === "rules-view") && L && /* @__PURE__ */ t(
69
- G,
75
+ (!o || o && u === "rules-view") && D && /* @__PURE__ */ t(
76
+ K,
70
77
  {
71
- dataItem: D,
72
- setActiveRule: w,
73
- setView: m,
78
+ dataItem: b,
79
+ setActiveRule: C,
80
+ setView: c,
74
81
  isIO: o,
75
82
  closeIOModal: r,
76
83
  genericTaggingEvent: s
77
84
  }
78
85
  ),
79
- (!o || o && n === "overwrite-view") && u && !C && /* @__PURE__ */ t(
80
- H,
86
+ (!o || o && u === "overwrite-view") && m && !y && /* @__PURE__ */ t(
87
+ P,
81
88
  {
82
- firstCouponName: y,
83
- secondCouponName: u,
84
- setView: m,
85
- setReplaceCoupon: d,
86
- setSecondCouponName: V,
89
+ firstCouponName: d,
90
+ secondCouponName: m,
91
+ setView: c,
92
+ setReplaceCoupon: N,
93
+ setSecondCouponName: R,
87
94
  isIO: o,
88
95
  closeIOModal: r,
89
96
  genericTaggingEvent: s
90
97
  }
91
98
  ),
92
- !i && A && /* @__PURE__ */ t(
93
- K,
99
+ !i && J && /* @__PURE__ */ t(
100
+ Q,
94
101
  {
95
- setIsCloseModalEmpty: v,
102
+ setIsCloseModalEmpty: V,
96
103
  genericTaggingEvent: s
97
104
  }
98
105
  )
99
106
  ] });
100
107
  };
101
108
  export {
102
- M as Coupons
109
+ I as Coupons
103
110
  };
@@ -1,8 +1,8 @@
1
1
  import o from "axios";
2
- const e = async (n, p, t) => {
3
- const a = `https://${n}.vtex.app/api/coupon/list`, s = Math.random(), { data: r } = t ? await o.post(a, { couponsList: t }) : await o.get(a, { params: { builder: p, random: s } });
2
+ const i = async (p, s, t) => {
3
+ const a = t ? "https://sfj-b0d92d8--smrholding.preview.vtex.app/api/coupon/list" : `https://${p}.vtex.app/api/coupon/list`, n = Math.random(), { data: r } = t ? await o.post(a, { couponsList: t }) : await o.get(a, { params: { builder: s, random: n } });
4
4
  return r.coupons;
5
5
  };
6
6
  export {
7
- e as getCoupons
7
+ i as getCoupons
8
8
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@plurix/ecom-components",
3
3
  "author": "Plurix",
4
4
  "private": false,
5
- "version": "1.7.0-loyalty.0",
5
+ "version": "1.8.0",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",