@plurix/ecom-components 0.0.2-beta.2 → 0.0.2-beta.4

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 (166) hide show
  1. package/dist/assets/svgs/ArrowIcon.d.ts +9 -0
  2. package/dist/assets/svgs/ArrowIcon.js +37 -0
  3. package/dist/assets/svgs/CartEmptyCoupon.d.ts +1 -0
  4. package/dist/assets/svgs/CartEmptyCoupon.js +937 -0
  5. package/dist/assets/svgs/CloseIcon.d.ts +7 -1
  6. package/dist/assets/svgs/CloseIcon.js +13 -9
  7. package/dist/assets/svgs/CouponIcon.d.ts +4 -0
  8. package/dist/assets/svgs/CouponIcon.js +22 -0
  9. package/dist/assets/svgs/DeliveryExpressIcon.d.ts +1 -0
  10. package/dist/assets/svgs/DeliveryExpressIcon.js +21 -0
  11. package/dist/assets/svgs/DeliveryIcon.d.ts +1 -0
  12. package/dist/assets/svgs/DeliveryIcon.js +21 -0
  13. package/dist/assets/svgs/ErrorIcon.d.ts +5 -0
  14. package/dist/assets/svgs/ErrorIcon.js +29 -0
  15. package/dist/assets/svgs/GlassIcon.d.ts +1 -0
  16. package/dist/assets/svgs/GlassIcon.js +23 -0
  17. package/dist/assets/svgs/InfoIcon.d.ts +6 -0
  18. package/dist/assets/svgs/InfoIcon.js +47 -0
  19. package/dist/assets/svgs/NoCouponIcon.d.ts +1 -0
  20. package/dist/assets/svgs/NoCouponIcon.js +107 -0
  21. package/dist/assets/svgs/ShoppingBagsIcon.d.ts +1 -0
  22. package/dist/assets/svgs/ShoppingBagsIcon.js +30 -0
  23. package/dist/assets/svgs/ShoppingIcon.d.ts +1 -0
  24. package/dist/assets/svgs/ShoppingIcon.js +21 -0
  25. package/dist/assets/svgs/SuccessIcon.d.ts +6 -0
  26. package/dist/assets/svgs/SuccessIcon.js +38 -0
  27. package/dist/assets/svgs/WarningIcon.d.ts +1 -0
  28. package/dist/assets/svgs/WarningIcon.js +25 -0
  29. package/dist/main.d.ts +5 -0
  30. package/dist/main.js +11 -3
  31. package/dist/packages/Carousel/Carousel.d.ts +24 -0
  32. package/dist/packages/Carousel/Carousel.js +128 -0
  33. package/dist/packages/Carousel/components/Arrows.d.ts +8 -0
  34. package/dist/packages/Carousel/components/Arrows.js +43 -0
  35. package/dist/packages/Carousel/components/Bullets.d.ts +7 -0
  36. package/dist/packages/Carousel/components/Bullets.js +5 -0
  37. package/dist/packages/Carousel/test/Carrousel.test.js +80 -0
  38. package/dist/packages/Carousel/utils/defaultProps.d.ts +19 -0
  39. package/dist/packages/Carousel/utils/defaultProps.js +22 -0
  40. package/dist/packages/Coupons/Coupons.d.ts +14 -0
  41. package/dist/packages/Coupons/Coupons.js +100 -0
  42. package/dist/packages/Coupons/api/addCoupon.d.ts +3 -0
  43. package/dist/packages/Coupons/api/addCoupon.js +14 -0
  44. package/dist/packages/Coupons/api/getCoupons.d.ts +3 -0
  45. package/dist/packages/Coupons/api/getCoupons.js +15 -0
  46. package/dist/packages/Coupons/api/removeCoupon.d.ts +3 -0
  47. package/dist/packages/Coupons/api/removeCoupon.js +13 -0
  48. package/dist/packages/Coupons/components/Alert.d.ts +6 -0
  49. package/dist/packages/Coupons/components/Alert.js +13 -0
  50. package/dist/packages/Coupons/components/Breadcrumb.d.ts +6 -0
  51. package/dist/packages/Coupons/components/Breadcrumb.js +33 -0
  52. package/dist/packages/Coupons/components/CouponCard.d.ts +25 -0
  53. package/dist/packages/Coupons/components/CouponCard.js +132 -0
  54. package/dist/packages/Coupons/components/Modal.d.ts +8 -0
  55. package/dist/packages/Coupons/components/Modal.js +34 -0
  56. package/dist/packages/Coupons/components/ModalFooter.d.ts +8 -0
  57. package/dist/packages/Coupons/components/ModalFooter.js +14 -0
  58. package/dist/packages/Coupons/components/ModalHeader.d.ts +6 -0
  59. package/dist/packages/Coupons/components/ModalHeader.js +25 -0
  60. package/dist/packages/Coupons/components/NoCoupons.d.ts +1 -0
  61. package/dist/packages/Coupons/components/NoCoupons.js +10 -0
  62. package/dist/packages/Coupons/test/Alert.test.js +18 -0
  63. package/dist/packages/Coupons/test/Breadcrumb.test.js +41 -0
  64. package/dist/packages/Coupons/test/ModalFooter.test.js +32 -0
  65. package/dist/packages/Coupons/test/ModalHeader.test.js +23 -0
  66. package/dist/packages/Coupons/test/NoCoupons.test.js +17 -0
  67. package/dist/packages/Coupons/types/CouponType.d.ts +8 -0
  68. package/dist/packages/Coupons/types/CouponType.js +1 -0
  69. package/dist/packages/Coupons/types/SetOrderFormCouponResponse.d.ts +10 -0
  70. package/dist/packages/Coupons/types/SetOrderFormCouponResponse.js +1 -0
  71. package/dist/packages/Coupons/types/Views.d.ts +1 -0
  72. package/dist/packages/Coupons/types/Views.js +1 -0
  73. package/dist/packages/Coupons/views/CouponsView.d.ts +13 -0
  74. package/dist/packages/Coupons/views/CouponsView.js +122 -0
  75. package/dist/packages/Coupons/views/EmptyCartView.d.ts +6 -0
  76. package/dist/packages/Coupons/views/EmptyCartView.js +37 -0
  77. package/dist/packages/Coupons/views/LoadingView.d.ts +7 -0
  78. package/dist/packages/Coupons/views/LoadingView.js +39 -0
  79. package/dist/packages/Coupons/views/OverwriteView.d.ts +14 -0
  80. package/dist/packages/Coupons/views/OverwriteView.js +58 -0
  81. package/dist/packages/Coupons/views/RulesView.d.ts +13 -0
  82. package/dist/packages/Coupons/views/RulesView.js +49 -0
  83. package/dist/packages/Coupons/views/index.d.ts +5 -0
  84. package/dist/packages/Coupons/views/index.js +12 -0
  85. package/dist/packages/Regionalization/Regionalization.d.ts +3 -0
  86. package/dist/packages/Regionalization/Regionalization.js +93 -0
  87. package/dist/packages/Regionalization/components/Delivery.d.ts +24 -0
  88. package/dist/packages/Regionalization/components/Delivery.js +48 -0
  89. package/dist/packages/Regionalization/components/DeliveryExpress.d.ts +9 -0
  90. package/dist/packages/Regionalization/components/DeliveryExpress.js +25 -0
  91. package/dist/packages/Regionalization/components/InfoPrices.d.ts +9 -0
  92. package/dist/packages/Regionalization/components/InfoPrices.js +15 -0
  93. package/dist/packages/Regionalization/components/Navigation.d.ts +6 -0
  94. package/dist/packages/Regionalization/components/Navigation.js +59 -0
  95. package/dist/packages/Regionalization/components/NormalDelivery.d.ts +7 -0
  96. package/dist/packages/Regionalization/components/NormalDelivery.js +23 -0
  97. package/dist/packages/Regionalization/components/PickupPoint.d.ts +7 -0
  98. package/dist/packages/Regionalization/components/PickupPoint.js +32 -0
  99. package/dist/packages/Regionalization/components/Price.d.ts +7 -0
  100. package/dist/packages/Regionalization/components/Price.js +10 -0
  101. package/dist/packages/Regionalization/components/SetViewButton.d.ts +11 -0
  102. package/dist/packages/Regionalization/components/SetViewButton.js +24 -0
  103. package/dist/packages/Regionalization/components/Title.d.ts +8 -0
  104. package/dist/packages/Regionalization/components/Title.js +21 -0
  105. package/dist/packages/Regionalization/context/RegionalizationContext.d.ts +4 -0
  106. package/dist/packages/Regionalization/context/RegionalizationContext.js +113 -0
  107. package/dist/packages/Regionalization/types/Address.d.ts +13 -0
  108. package/dist/packages/Regionalization/types/Address.js +1 -0
  109. package/dist/packages/Regionalization/types/ContextProps.d.ts +29 -0
  110. package/dist/packages/Regionalization/types/ContextProps.js +1 -0
  111. package/dist/packages/Regionalization/types/PikcupPointType.d.ts +22 -0
  112. package/dist/packages/Regionalization/types/PikcupPointType.js +1 -0
  113. package/dist/packages/Regionalization/types/PricesAndHours.d.ts +13 -0
  114. package/dist/packages/Regionalization/types/PricesAndHours.js +1 -0
  115. package/dist/packages/Regionalization/types/RegionalizationProps.d.ts +87 -0
  116. package/dist/packages/Regionalization/types/RegionalizationProps.js +1 -0
  117. package/dist/packages/Regionalization/types/index.d.ts +5 -0
  118. package/dist/packages/Regionalization/types/index.js +1 -0
  119. package/dist/packages/Regionalization/utils/constants.d.ts +1 -0
  120. package/dist/packages/Regionalization/utils/constants.js +4 -0
  121. package/dist/packages/Regionalization/utils/deliverySetData.d.ts +3 -0
  122. package/dist/packages/Regionalization/utils/deliverySetData.js +13 -0
  123. package/dist/packages/Regionalization/utils/formatPrice.d.ts +1 -0
  124. package/dist/packages/Regionalization/utils/formatPrice.js +8 -0
  125. package/dist/packages/Regionalization/utils/localStorage.d.ts +9 -0
  126. package/dist/packages/Regionalization/utils/localStorage.js +23 -0
  127. package/dist/packages/Regionalization/utils/pickupSetData.d.ts +3 -0
  128. package/dist/packages/Regionalization/utils/pickupSetData.js +11 -0
  129. package/dist/packages/Regionalization/utils/postalCode.d.ts +2 -0
  130. package/dist/packages/Regionalization/utils/postalCode.js +9 -0
  131. package/dist/packages/Regionalization/views/AllStoresScreen.d.ts +1 -0
  132. package/dist/packages/Regionalization/views/AllStoresScreen.js +73 -0
  133. package/dist/packages/Regionalization/views/ConfirmScreen.d.ts +1 -0
  134. package/dist/packages/Regionalization/views/ConfirmScreen.js +60 -0
  135. package/dist/packages/Regionalization/views/InitialView.d.ts +1 -0
  136. package/dist/packages/Regionalization/views/InitialView.js +49 -0
  137. package/dist/packages/Regionalization/views/MoreInfosScreen.d.ts +1 -0
  138. package/dist/packages/Regionalization/views/MoreInfosScreen.js +42 -0
  139. package/dist/packages/Regionalization/views/PickupPointInfoScreen.d.ts +1 -0
  140. package/dist/packages/Regionalization/views/PickupPointInfoScreen.js +42 -0
  141. package/dist/packages/Regionalization/views/PostalCodeInputScreen.d.ts +1 -0
  142. package/dist/packages/Regionalization/views/PostalCodeInputScreen.js +87 -0
  143. package/dist/packages/Regionalization/views/ViewsContainer.d.ts +1 -0
  144. package/dist/packages/Regionalization/views/ViewsContainer.js +22 -0
  145. package/dist/packages/Tour/Tour.d.ts +10 -0
  146. package/dist/packages/Tour/Tour.js +68 -0
  147. package/dist/packages/Tour/components/TooltipFooter.d.ts +11 -0
  148. package/dist/packages/Tour/components/TooltipFooter.js +14 -0
  149. package/dist/packages/Tour/components/TooltipHeader.d.ts +8 -0
  150. package/dist/packages/Tour/components/TooltipHeader.js +13 -0
  151. package/dist/packages/Tour/components/TourOverlay.d.ts +7 -0
  152. package/dist/packages/Tour/components/TourOverlay.js +12 -0
  153. package/dist/packages/Tour/components/TourTooltip.d.ts +17 -0
  154. package/dist/packages/Tour/components/TourTooltip.js +42 -0
  155. package/dist/packages/Tour/test/TooltipFooter.test.js +68 -0
  156. package/dist/packages/Tour/test/TooltipHeader.test.js +18 -0
  157. package/dist/packages/Tour/test/Tour.test.js +49 -0
  158. package/dist/packages/Tour/test/TourOverlay.test.js +18 -0
  159. package/dist/packages/Tour/test/TourTooltip.test.js +40 -0
  160. package/dist/packages/Tour/types/TourStep.d.ts +4 -0
  161. package/dist/packages/Tour/types/TourStep.js +1 -0
  162. package/dist/styles/carousel.global.css +1 -0
  163. package/dist/styles/coupons.global.css +1 -0
  164. package/dist/styles/regionalization.global.css +1 -0
  165. package/dist/styles/tour.global.css +1 -0
  166. package/package.json +5 -1
@@ -0,0 +1,132 @@
1
+ import { jsxs as u, jsx as s } from "react/jsx-runtime";
2
+ import { useState as V, useEffect as B } from "react";
3
+ import { addCoupon as G } from "../api/addCoupon.js";
4
+ import { removeCoupon as H } from "../api/removeCoupon.js";
5
+ import { CouponIcon as I } from "../../../assets/svgs/CouponIcon.js";
6
+ import { SuccessIcon as J } from "../../../assets/svgs/SuccessIcon.js";
7
+ const W = ({
8
+ account: L,
9
+ orderFormId: _,
10
+ hasItemsInCart: x,
11
+ isIO: z = !1,
12
+ item: l,
13
+ firstCouponName: c,
14
+ secondCouponName: p,
15
+ replaceCoupon: h,
16
+ setView: D,
17
+ setActiveRule: N,
18
+ setDataItem: M,
19
+ setFirstCouponName: t,
20
+ setSecondCouponName: b,
21
+ setReplaceCoupon: j,
22
+ setAlert: m,
23
+ setType: d,
24
+ setIsCloseModalEmpty: y,
25
+ genericTaggingEvent: o
26
+ }) => {
27
+ const [w, r] = V(!1), [k, f] = V(!1);
28
+ B(() => {
29
+ p.toLowerCase() !== l.couponName.toLowerCase() && r(!1), c && !p && c.toLowerCase() === l.couponName.toLowerCase() && r(!0), c && p && h && p.toLowerCase() === l.couponName.toLowerCase() && A(p);
30
+ }, [c, p, h]);
31
+ const A = async (a) => {
32
+ if (x)
33
+ try {
34
+ if (!c || c && h) {
35
+ f(!0);
36
+ const R = await G(L, _, a);
37
+ j(!1), t(a), b(""), R.error.length <= 0 ? (o == null || o("discount_coupon", {
38
+ name: "cupom aplicado",
39
+ cupomName: a
40
+ }), d("success"), r(!0), z && window.location.reload()) : (o == null || o("discount_coupon", {
41
+ name: "cupom aplicando - cupom incorreto ou expirado",
42
+ cupomName: a,
43
+ objectError: R.error
44
+ }), d("error"), r(!1), t("")), m(!0);
45
+ } else
46
+ b(a), D("overwrite-view");
47
+ } catch {
48
+ o == null || o("discount_coupon", {
49
+ name: "problema na api",
50
+ cupomName: a
51
+ }), r(!1), d("error"), m(!0);
52
+ } finally {
53
+ f(!1);
54
+ }
55
+ else
56
+ o == null || o("discount_coupon", {
57
+ name: "Modal de cart vazio acionado"
58
+ }), y(!0);
59
+ }, $ = async () => {
60
+ if (x)
61
+ try {
62
+ f(!0), j(!1);
63
+ const a = await H(L, _);
64
+ a.error.length <= 0 ? (o == null || o("discount_coupon", {
65
+ name: "cupom removido com sucesso",
66
+ cupomName: c
67
+ }), d("removed"), r(!1), t(""), b("")) : (o == null || o("discount_coupon", {
68
+ name: "algum problema na remoção do cupom",
69
+ cupomName: c,
70
+ objectError: a.error
71
+ }), d("error"), r(!0)), m(!0);
72
+ } catch {
73
+ o == null || o("discount_coupon", {
74
+ name: "problema na api - na remoção do cupom",
75
+ cupomName: c
76
+ }), d("error"), r(!0), m(!0);
77
+ } finally {
78
+ f(!1);
79
+ }
80
+ else
81
+ o == null || o("discount_coupon", {
82
+ name: "Modal de cart vazio acionado"
83
+ }), y(!0);
84
+ }, q = () => {
85
+ N(!0), M(l), D("rules-view");
86
+ };
87
+ return /* @__PURE__ */ u("div", { className: `container-card-coupon ${w ? "active" : ""}`, children: [
88
+ /* @__PURE__ */ u("div", { className: "text-container", children: [
89
+ /* @__PURE__ */ u("div", { className: "container-title", children: [
90
+ /* @__PURE__ */ s(I, { width: 20, height: 16 }),
91
+ /* @__PURE__ */ s("p", { className: "title", children: l.couponName })
92
+ ] }),
93
+ l.couponValue && /* @__PURE__ */ u("p", { className: "price-badge", children: [
94
+ "- ",
95
+ l.couponValue
96
+ ] }),
97
+ l.couponDescription && /* @__PURE__ */ s("p", { className: "subtitle", children: l.couponDescription }),
98
+ l.couponExpirationDate && /* @__PURE__ */ u("p", { className: "subtitle", children: [
99
+ "Válido até ",
100
+ l.couponExpirationDate
101
+ ] })
102
+ ] }),
103
+ /* @__PURE__ */ s("div", { className: "vertical-line" }),
104
+ /* @__PURE__ */ u("div", { className: "buttons-container", children: [
105
+ w && /* @__PURE__ */ u("button", { className: "applied-coupon", children: [
106
+ /* @__PURE__ */ s("span", { className: "applied-coupon-span", children: /* @__PURE__ */ s(J, {}) }),
107
+ "Aplicado"
108
+ ] }),
109
+ w ? /* @__PURE__ */ s(
110
+ "button",
111
+ {
112
+ onClick: $,
113
+ className: "remove-coupon",
114
+ disabled: k,
115
+ children: "Remover"
116
+ }
117
+ ) : /* @__PURE__ */ s(
118
+ "button",
119
+ {
120
+ onClick: () => A(l.couponName),
121
+ className: "apply-coupon",
122
+ disabled: k,
123
+ children: "Aplicar"
124
+ }
125
+ ),
126
+ l.couponDescription && /* @__PURE__ */ s("a", { onClick: q, children: "Ver Regras" })
127
+ ] })
128
+ ] });
129
+ };
130
+ export {
131
+ W as CouponCard
132
+ };
@@ -0,0 +1,8 @@
1
+ import { ModalHeaderProps } from './ModalHeader';
2
+ import { ModalFooterProps } from './ModalFooter';
3
+
4
+ interface ModalProps extends ModalHeaderProps, ModalFooterProps {
5
+ isIO?: boolean;
6
+ }
7
+ export declare const Modal: ({ children, isIO, closeModal, title, genericTaggingEvent, cancelButtonAction, ...modalFooterProps }: React.PropsWithChildren<ModalProps>) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,34 @@
1
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
2
+ import { ModalHeader as c } from "./ModalHeader.js";
3
+ import { Breadcrumb as n } from "./Breadcrumb.js";
4
+ import { ModalFooter as p } from "./ModalFooter.js";
5
+ const h = ({
6
+ children: a,
7
+ isIO: l = !1,
8
+ closeModal: m,
9
+ title: o,
10
+ genericTaggingEvent: d,
11
+ cancelButtonAction: e,
12
+ ...s
13
+ }) => /* @__PURE__ */ r("div", { className: "modal-rule-coupon-external", children: /* @__PURE__ */ i("div", { className: "modal-rule-coupon-internal", children: [
14
+ /* @__PURE__ */ r(
15
+ c,
16
+ {
17
+ closeModal: m,
18
+ title: o,
19
+ genericTaggingEvent: d
20
+ }
21
+ ),
22
+ l && /* @__PURE__ */ r(n, { title: o, cancelButtonAction: e }),
23
+ /* @__PURE__ */ r("div", { className: "modal-rule-coupon-children", children: a }),
24
+ /* @__PURE__ */ r(
25
+ p,
26
+ {
27
+ cancelButtonAction: e,
28
+ ...s
29
+ }
30
+ )
31
+ ] }) });
32
+ export {
33
+ h as Modal
34
+ };
@@ -0,0 +1,8 @@
1
+ export interface ModalFooterProps {
2
+ cancelButtonAction: () => void;
3
+ cancelButtonText: string;
4
+ confirmButtonAction?: () => void;
5
+ confirmButtonText?: string;
6
+ isFloating?: boolean;
7
+ }
8
+ export declare const ModalFooter: ({ cancelButtonAction, cancelButtonText, confirmButtonAction, confirmButtonText, isFloating }: ModalFooterProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsxs as r, jsx as a } from "react/jsx-runtime";
2
+ const t = ({
3
+ cancelButtonAction: e,
4
+ cancelButtonText: n,
5
+ confirmButtonAction: o,
6
+ confirmButtonText: l,
7
+ isFloating: c
8
+ }) => /* @__PURE__ */ r("div", { className: `modal-footer-container ${c ? "floating" : ""}`, children: [
9
+ o && l && /* @__PURE__ */ a("button", { onClick: o, className: "modal-confirm-button", children: l }),
10
+ /* @__PURE__ */ a("button", { onClick: e, className: "modal-cancel-button", children: n })
11
+ ] });
12
+ export {
13
+ t as ModalFooter
14
+ };
@@ -0,0 +1,6 @@
1
+ export interface ModalHeaderProps {
2
+ closeModal: () => void;
3
+ title: string;
4
+ genericTaggingEvent?: (name: string, params: object) => void;
5
+ }
6
+ export declare const ModalHeader: ({ closeModal, title, genericTaggingEvent }: ModalHeaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { jsxs as a, jsx as l } from "react/jsx-runtime";
2
+ import { CloseIcon as t } from "../../../assets/svgs/CloseIcon.js";
3
+ const r = ({
4
+ closeModal: d,
5
+ title: s,
6
+ genericTaggingEvent: o
7
+ }) => /* @__PURE__ */ a("div", { className: "modal-title-container", children: [
8
+ /* @__PURE__ */ l("h1", { className: "modal-title", children: s }),
9
+ /* @__PURE__ */ l(
10
+ "button",
11
+ {
12
+ onClick: () => {
13
+ o == null || o("discount_coupon", {
14
+ name: "Modal fechado no X"
15
+ }), d();
16
+ },
17
+ className: "modal-close-icon",
18
+ "data-testid": "close-button",
19
+ children: /* @__PURE__ */ l(t, {})
20
+ }
21
+ )
22
+ ] });
23
+ export {
24
+ r as ModalHeader
25
+ };
@@ -0,0 +1 @@
1
+ export declare const NoCoupons: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsxs as s, jsx as o } from "react/jsx-runtime";
2
+ import { NoCouponsIcon as n } from "../../../assets/svgs/NoCouponIcon.js";
3
+ const c = () => /* @__PURE__ */ s("div", { className: "noCoupons", children: [
4
+ /* @__PURE__ */ o("h1", { className: "noCoupons-h1", children: "Não há cupons disponíveis no momento" }),
5
+ /* @__PURE__ */ o("p", { className: "noCoupons-p", children: "Aqui você verá todos os cupons disponíveis para aplicar" }),
6
+ /* @__PURE__ */ o(n, {})
7
+ ] });
8
+ export {
9
+ c as NoCoupons
10
+ };
@@ -0,0 +1,18 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { render as r } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+ import { Alert as s } from "../components/Alert.js";
5
+ describe("Alert component tests", () => {
6
+ it('renders success alert when type is "success"', () => {
7
+ const { getByTestId: e, getByText: t } = r(/* @__PURE__ */ o(s, { type: "success" }));
8
+ expect(e("success-icon")).toBeInTheDocument(), expect(t("Cupom aplicado com sucesso")).toBeInTheDocument();
9
+ }), it('renders removed alert when type is "removed"', () => {
10
+ const { getByText: e, getByTestId: t } = r(/* @__PURE__ */ o(s, { type: "removed" }));
11
+ expect(t("success-icon")).toBeInTheDocument(), expect(e("Cupom removido com sucesso")).toBeInTheDocument();
12
+ }), it('renders error alert when type is "error"', () => {
13
+ const { getByTestId: e, getByText: t } = r(/* @__PURE__ */ o(s, { type: "error" }));
14
+ expect(e("error-icon")).toBeInTheDocument(), expect(
15
+ t("Não foi possível aplicar o cupom. Tente aplicar mais tarde.")
16
+ ).toBeInTheDocument();
17
+ });
18
+ });
@@ -0,0 +1,41 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { render as n, fireEvent as i } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+ import { Breadcrumb as l } from "../components/Breadcrumb.js";
5
+ const c = "Test Title", e = jest.fn();
6
+ describe("Breadcrumb component tests", () => {
7
+ it("should render correctly", () => {
8
+ const { getByTestId: t, getByText: u } = n(
9
+ /* @__PURE__ */ o(
10
+ l,
11
+ {
12
+ title: c,
13
+ cancelButtonAction: e
14
+ }
15
+ )
16
+ );
17
+ expect(t("back-to-coupons-button")).toBeInTheDocument(), expect(u(c)).toBeInTheDocument(), expect(t("back-button")).toBeInTheDocument();
18
+ }), it("should call cancelButtonAction when the button is clicked", () => {
19
+ const { getByTestId: t } = n(
20
+ /* @__PURE__ */ o(
21
+ l,
22
+ {
23
+ title: c,
24
+ cancelButtonAction: e
25
+ }
26
+ )
27
+ );
28
+ i.click(t("back-to-coupons-button")), expect(e).toHaveBeenCalled();
29
+ }), it("should call cancelButtonAction when the back button is clicked", () => {
30
+ const { getByTestId: t } = n(
31
+ /* @__PURE__ */ o(
32
+ l,
33
+ {
34
+ title: c,
35
+ cancelButtonAction: e
36
+ }
37
+ )
38
+ );
39
+ i.click(t("back-button")), expect(e).toHaveBeenCalled();
40
+ });
41
+ });
@@ -0,0 +1,32 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { render as o, fireEvent as l } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+ import { ModalFooter as n } from "../components/ModalFooter.js";
5
+ const a = jest.fn(), i = "Cancel", r = jest.fn(), s = "Confirm", h = !0, c = {
6
+ cancelButtonAction: a,
7
+ cancelButtonText: i,
8
+ confirmButtonAction: r,
9
+ confirmButtonText: s,
10
+ isFloating: h
11
+ };
12
+ describe("ModalFooter component tests", () => {
13
+ it("should render the cancel button with the correct text", () => {
14
+ const { getByText: t } = o(/* @__PURE__ */ e(n, { ...c }));
15
+ expect(t(i)).toBeInTheDocument();
16
+ }), it("should call the cancel button action when clicked", () => {
17
+ const { getByText: t } = o(/* @__PURE__ */ e(n, { ...c }));
18
+ l.click(t(i)), expect(a).toHaveBeenCalled();
19
+ }), it("should render the confirm button with the correct text", () => {
20
+ const { getByText: t } = o(/* @__PURE__ */ e(n, { ...c }));
21
+ expect(t(s)).toBeInTheDocument();
22
+ }), it("should call the confirm button action when clicked", () => {
23
+ const { getByText: t } = o(/* @__PURE__ */ e(n, { ...c }));
24
+ l.click(t(s)), expect(r).toHaveBeenCalled();
25
+ }), it('should add the "floating" class to the container when isFloating is true', () => {
26
+ const { container: t } = o(/* @__PURE__ */ e(n, { ...c }));
27
+ expect(t.firstChild).toHaveClass("floating");
28
+ }), it('should not add the "floating" class to the container when isFloating is false', () => {
29
+ const { container: t } = o(/* @__PURE__ */ e(n, { ...c, isFloating: !1 }));
30
+ expect(t.firstChild).not.toHaveClass("floating");
31
+ });
32
+ });
@@ -0,0 +1,23 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { render as o, fireEvent as l } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+ import { ModalHeader as c } from "../components/ModalHeader.js";
5
+ const s = jest.fn(), d = "Test Modal", i = jest.fn(), n = {
6
+ closeModal: s,
7
+ title: d,
8
+ genericTaggingEvent: i
9
+ };
10
+ describe("ModalHeader component tests", () => {
11
+ it("should render the modal header with the correct title", () => {
12
+ const { getByText: e } = o(/* @__PURE__ */ t(c, { ...n }));
13
+ expect(e("Test Modal")).toBeInTheDocument();
14
+ }), it("should call the closeModal function when the close button is clicked", () => {
15
+ const { getByTestId: e } = o(/* @__PURE__ */ t(c, { ...n }));
16
+ l.click(e("close-button")), expect(s).toHaveBeenCalled();
17
+ }), it("should call the genericTaggingEvent function when the close button is clicked", () => {
18
+ const { getByTestId: e } = o(/* @__PURE__ */ t(c, { ...n }));
19
+ l.click(e("close-button")), expect(i).toHaveBeenCalledWith("discount_coupon", {
20
+ name: "Modal fechado no X"
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,17 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { render as t } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+ import { NoCoupons as n } from "../components/NoCoupons.js";
5
+ describe("NoCoupons component tests", () => {
6
+ it("renders the correct text", () => {
7
+ const { getByText: o } = t(/* @__PURE__ */ e(n, {}));
8
+ expect(
9
+ o("Não há cupons disponíveis no momento")
10
+ ).toBeInTheDocument(), expect(
11
+ o("Aqui você verá todos os cupons disponíveis para aplicar")
12
+ ).toBeInTheDocument();
13
+ }), it("renders the NoCouponsIcon component", () => {
14
+ const { getByTestId: o } = t(/* @__PURE__ */ e(n, {}));
15
+ expect(o("no-coupons-icon")).toBeInTheDocument();
16
+ });
17
+ });
@@ -0,0 +1,8 @@
1
+ export interface CouponType {
2
+ couponName: string;
3
+ couponValue: string;
4
+ couponDescription: string;
5
+ couponRules: Array<string>;
6
+ couponInitialDate: string;
7
+ couponExpirationDate: string;
8
+ }
@@ -0,0 +1,10 @@
1
+ export interface SetOrderFormCouponResponse {
2
+ coupon: string;
3
+ error: CouponError[];
4
+ }
5
+ interface CouponError {
6
+ text: string;
7
+ status?: string;
8
+ code?: string;
9
+ }
10
+ export {};
@@ -0,0 +1 @@
1
+ export type View = 'coupons-view' | 'rules-view' | 'overwrite-view';
@@ -0,0 +1,13 @@
1
+ import { CouponCardProps } from '../components/CouponCard';
2
+ import { CouponType } from '../types/CouponType';
3
+
4
+ type OmittedProps = 'item' | 'setType' | 'setAlert';
5
+ interface CouponsViewProps extends Omit<CouponCardProps, OmittedProps> {
6
+ account: string;
7
+ orderFormId: string;
8
+ hasItemsInCart: boolean;
9
+ closeIOModal?: () => void;
10
+ coupons: CouponType[];
11
+ }
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;
13
+ export {};
@@ -0,0 +1,122 @@
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: y,
12
+ orderFormId: b,
13
+ hasItemsInCart: x,
14
+ isIO: p,
15
+ closeIOModal: u,
16
+ coupons: c,
17
+ firstCouponName: i,
18
+ secondCouponName: _,
19
+ replaceCoupon: C,
20
+ setView: w,
21
+ setActiveRule: D,
22
+ setDataItem: L,
23
+ setFirstCouponName: m,
24
+ setSecondCouponName: n,
25
+ setReplaceCoupon: A,
26
+ setIsCloseModalEmpty: S,
27
+ genericTaggingEvent: r
28
+ }) => {
29
+ const [t, q] = a(""), [H, B] = 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();
33
+ try {
34
+ if (!i || i && C) {
35
+ B(!0);
36
+ const j = await G(y, b, t);
37
+ A(!1), n(""), j.error.length <= 0 ? (r == null || r("discount_coupon", {
38
+ name: "Cupom aplicado do input",
39
+ couponName: t
40
+ }), s("success"), h(!0), m(t), p && window.location.reload()) : (r == null || r("discount_coupon", {
41
+ name: "Cupom do input expirado ou invalido",
42
+ couponName: t,
43
+ objectError: j.error
44
+ }), s("error"), h(!1), m("")), d(!0);
45
+ } else
46
+ n(t), w("overwrite-view");
47
+ } catch {
48
+ r == null || r("discount_coupon", {
49
+ name: "Cupom do input - error na api",
50
+ couponName: t
51
+ }), s("error"), h(!1), d(!0);
52
+ } finally {
53
+ B(!1);
54
+ }
55
+ };
56
+ return F(() => {
57
+ f && setTimeout(() => d(!1), 5e3);
58
+ }, [P, f]), /* @__PURE__ */ e(N, { children: [
59
+ p && u && /* @__PURE__ */ o(
60
+ J,
61
+ {
62
+ closeModal: u,
63
+ title: "Meus Cupons",
64
+ genericTaggingEvent: r
65
+ }
66
+ ),
67
+ x ? /* @__PURE__ */ o("div", { className: "form-coupons", children: /* @__PURE__ */ e("form", { onSubmit: z, children: [
68
+ /* @__PURE__ */ o(
69
+ "input",
70
+ {
71
+ type: "text",
72
+ placeholder: "Insira o cupom",
73
+ value: t,
74
+ onChange: k
75
+ }
76
+ ),
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, {}) }),
80
+ "Para adicionar um cupom é necessário que você adicione pelo menos 1 produto no carrinho"
81
+ ] }) }),
82
+ /* @__PURE__ */ o("div", { className: "container-title-coupons", children: c.length > 0 ? /* @__PURE__ */ e(N, { children: [
83
+ /* @__PURE__ */ o("h1", { children: "Cupons disponíveis" }),
84
+ /* @__PURE__ */ o("div", { className: "container-coupons", children: c.map((l) => /* @__PURE__ */ o(
85
+ Q,
86
+ {
87
+ account: y,
88
+ orderFormId: b,
89
+ hasItemsInCart: x,
90
+ isIO: p,
91
+ item: l,
92
+ firstCouponName: i,
93
+ secondCouponName: _,
94
+ replaceCoupon: C,
95
+ setView: w,
96
+ setFirstCouponName: m,
97
+ setSecondCouponName: n,
98
+ setActiveRule: D,
99
+ setDataItem: L,
100
+ setReplaceCoupon: A,
101
+ setAlert: d,
102
+ setType: s,
103
+ setIsCloseModalEmpty: S,
104
+ genericTaggingEvent: r
105
+ },
106
+ l.couponName
107
+ )) })
108
+ ] }) : /* @__PURE__ */ o(U, {}) }),
109
+ f && /* @__PURE__ */ o(V, { type: M }),
110
+ p && u && /* @__PURE__ */ o(
111
+ K,
112
+ {
113
+ isFloating: c.length > 0,
114
+ cancelButtonAction: u,
115
+ cancelButtonText: "Sair"
116
+ }
117
+ )
118
+ ] });
119
+ };
120
+ export {
121
+ E as CouponsView
122
+ };
@@ -0,0 +1,6 @@
1
+ interface EmptyCartViewProps {
2
+ setIsCloseModalEmpty: (isCloseModalEmpty: boolean) => void;
3
+ genericTaggingEvent?: (name: string, params: object) => void;
4
+ }
5
+ export declare const EmptyCartView: ({ setIsCloseModalEmpty, genericTaggingEvent }: EmptyCartViewProps) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,37 @@
1
+ import { jsxs as r, jsx as o } from "react/jsx-runtime";
2
+ import { Modal as s } from "../components/Modal.js";
3
+ import { CartEmptyCoupon as p } from "../../../assets/svgs/CartEmptyCoupon.js";
4
+ import { InfoIcon as n } from "../../../assets/svgs/InfoIcon.js";
5
+ const i = ({
6
+ setIsCloseModalEmpty: t,
7
+ genericTaggingEvent: a
8
+ }) => {
9
+ const c = () => {
10
+ t(!1);
11
+ };
12
+ return /* @__PURE__ */ r(
13
+ s,
14
+ {
15
+ closeModal: c,
16
+ title: "Cupons de desconto",
17
+ genericTaggingEvent: a,
18
+ cancelButtonText: "Voltar para Meus Cupons",
19
+ cancelButtonAction: () => {
20
+ a == null || a("discount_coupon", {
21
+ name: "Modal do cart vazio - botão de sair"
22
+ }), c();
23
+ },
24
+ children: [
25
+ /* @__PURE__ */ o("h3", { className: "cartEmptyCoupon-h3", children: "Ops...Parece que seu carrinho está vazio..." }),
26
+ /* @__PURE__ */ o("div", { className: "cartEmptyCoupon-svg", children: /* @__PURE__ */ o(p, {}) }),
27
+ /* @__PURE__ */ r("p", { id: "cartEmptyCoupon-p", children: [
28
+ /* @__PURE__ */ o("span", { children: /* @__PURE__ */ o(n, {}) }),
29
+ "Para adicionar um cupom é necessário que você adicione pelo menos 1 produto no carrinho"
30
+ ] })
31
+ ]
32
+ }
33
+ );
34
+ };
35
+ export {
36
+ i as EmptyCartView
37
+ };
@@ -0,0 +1,7 @@
1
+ interface LoadingViewProps {
2
+ isIO?: boolean;
3
+ closeIOModal?: () => void;
4
+ genericTaggingEvent?: (name: string, params: object) => void;
5
+ }
6
+ export declare const LoadingView: ({ isIO, closeIOModal, genericTaggingEvent }: LoadingViewProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,39 @@
1
+ import { jsxs as a, Fragment as n, jsx as r } from "react/jsx-runtime";
2
+ import { Skeleton as i } from "@acctglobal/skeleton";
3
+ import { ModalHeader as m } from "../components/ModalHeader.js";
4
+ import { ModalFooter as u } from "../components/ModalFooter.js";
5
+ const f = ({
6
+ isIO: t = !1,
7
+ closeIOModal: o,
8
+ genericTaggingEvent: e
9
+ }) => /* @__PURE__ */ a(n, { children: [
10
+ t && o && /* @__PURE__ */ r(
11
+ m,
12
+ {
13
+ closeModal: o,
14
+ title: "Meus Cupons",
15
+ genericTaggingEvent: e
16
+ }
17
+ ),
18
+ /* @__PURE__ */ r(
19
+ i,
20
+ {
21
+ width: t ? "100%" : "90%",
22
+ height: t ? 600 : 425,
23
+ backgroundColor: "var(--color-grayScale-faded)",
24
+ margin: "auto",
25
+ animation: !0
26
+ }
27
+ ),
28
+ t && o && /* @__PURE__ */ r(
29
+ u,
30
+ {
31
+ isFloating: !0,
32
+ cancelButtonAction: o,
33
+ cancelButtonText: "Sair"
34
+ }
35
+ )
36
+ ] });
37
+ export {
38
+ f as LoadingView
39
+ };