@agrada_digital/pbm 0.0.57 → 0.0.63
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.
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +192 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +192 -89
- package/dist/index.mjs.map +1 -1
- package/dist-wc/pbm-wc.js +106 -101
- package/package.json +12 -12
package/dist/index.d.mts
CHANGED
|
@@ -21,6 +21,8 @@ interface usePBMTypes {
|
|
|
21
21
|
};
|
|
22
22
|
campaign: "pbm_campaign";
|
|
23
23
|
targetProduct: IProduct | null;
|
|
24
|
+
urlAcceptTerms?: string;
|
|
25
|
+
urlRegisterIndustry?: string;
|
|
24
26
|
}
|
|
25
27
|
interface IProduct {
|
|
26
28
|
ean: string;
|
|
@@ -31,10 +33,13 @@ interface IProduct {
|
|
|
31
33
|
listPrice?: number;
|
|
32
34
|
stockBalance?: number;
|
|
33
35
|
productName?: string;
|
|
34
|
-
productId?:
|
|
36
|
+
productId?: number;
|
|
35
37
|
availabilityText?: string;
|
|
36
38
|
brandName?: string;
|
|
37
39
|
categoryName?: string;
|
|
40
|
+
netPrice?: number;
|
|
41
|
+
informativeMessage?: string;
|
|
42
|
+
discountMax?: number;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
interface PBMStore extends usePBMTypes {
|
|
@@ -42,6 +47,8 @@ interface PBMStore extends usePBMTypes {
|
|
|
42
47
|
setState: (state: usePBMTypes["state"]) => void;
|
|
43
48
|
setAvailableDiscountSelected: (availableDiscount: usePBMTypes["availableDiscountSelected"]) => void;
|
|
44
49
|
setTargetProduct: (targetProduct: usePBMTypes["targetProduct"]) => void;
|
|
50
|
+
setUrlAcceptTerms: (urlAcceptTerms: usePBMTypes["urlAcceptTerms"]) => void;
|
|
51
|
+
setUrlRegisterIndustry: (urlRegisterIndustry: usePBMTypes["urlRegisterIndustry"]) => void;
|
|
45
52
|
}
|
|
46
53
|
declare function usePBMStore(): PBMStore;
|
|
47
54
|
declare function usePBMStore<T>(selector: (state: PBMStore) => T): T;
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ interface usePBMTypes {
|
|
|
21
21
|
};
|
|
22
22
|
campaign: "pbm_campaign";
|
|
23
23
|
targetProduct: IProduct | null;
|
|
24
|
+
urlAcceptTerms?: string;
|
|
25
|
+
urlRegisterIndustry?: string;
|
|
24
26
|
}
|
|
25
27
|
interface IProduct {
|
|
26
28
|
ean: string;
|
|
@@ -31,10 +33,13 @@ interface IProduct {
|
|
|
31
33
|
listPrice?: number;
|
|
32
34
|
stockBalance?: number;
|
|
33
35
|
productName?: string;
|
|
34
|
-
productId?:
|
|
36
|
+
productId?: number;
|
|
35
37
|
availabilityText?: string;
|
|
36
38
|
brandName?: string;
|
|
37
39
|
categoryName?: string;
|
|
40
|
+
netPrice?: number;
|
|
41
|
+
informativeMessage?: string;
|
|
42
|
+
discountMax?: number;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
interface PBMStore extends usePBMTypes {
|
|
@@ -42,6 +47,8 @@ interface PBMStore extends usePBMTypes {
|
|
|
42
47
|
setState: (state: usePBMTypes["state"]) => void;
|
|
43
48
|
setAvailableDiscountSelected: (availableDiscount: usePBMTypes["availableDiscountSelected"]) => void;
|
|
44
49
|
setTargetProduct: (targetProduct: usePBMTypes["targetProduct"]) => void;
|
|
50
|
+
setUrlAcceptTerms: (urlAcceptTerms: usePBMTypes["urlAcceptTerms"]) => void;
|
|
51
|
+
setUrlRegisterIndustry: (urlRegisterIndustry: usePBMTypes["urlRegisterIndustry"]) => void;
|
|
45
52
|
}
|
|
46
53
|
declare function usePBMStore(): PBMStore;
|
|
47
54
|
declare function usePBMStore<T>(selector: (state: PBMStore) => T): T;
|
package/dist/index.js
CHANGED
|
@@ -35,30 +35,88 @@ __export(index_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
|
+
// src/libs/zustand/usePBM.tsx
|
|
39
|
+
var import_zustand = require("zustand");
|
|
40
|
+
var import_react = require("zustand/react");
|
|
41
|
+
var initialPBMState = {
|
|
42
|
+
securityNumber: "",
|
|
43
|
+
state: "isEmpty",
|
|
44
|
+
availableDiscountSelected: {
|
|
45
|
+
quantity: 0,
|
|
46
|
+
discount: {
|
|
47
|
+
unit: 0,
|
|
48
|
+
total: 0
|
|
49
|
+
},
|
|
50
|
+
totalPrice: 0
|
|
51
|
+
},
|
|
52
|
+
targetProduct: null,
|
|
53
|
+
campaign: "pbm_campaign"
|
|
54
|
+
};
|
|
55
|
+
var createPBMStore = (set) => ({
|
|
56
|
+
...initialPBMState,
|
|
57
|
+
setSecurityNumber: (securityNumber) => set({ securityNumber }),
|
|
58
|
+
setState: (state) => set({ state }),
|
|
59
|
+
setTargetProduct: (targetProduct) => set({ targetProduct }),
|
|
60
|
+
setAvailableDiscountSelected: (availableDiscount) => set({ availableDiscountSelected: availableDiscount }),
|
|
61
|
+
setUrlAcceptTerms: (urlAcceptTerms) => set({ urlAcceptTerms }),
|
|
62
|
+
setUrlRegisterIndustry: (urlRegisterIndustry) => set({ urlRegisterIndustry })
|
|
63
|
+
});
|
|
64
|
+
var pbmStore = (0, import_zustand.createStore)(createPBMStore);
|
|
65
|
+
function usePBMStore(selector) {
|
|
66
|
+
if (selector) {
|
|
67
|
+
return (0, import_react.useStore)(pbmStore, selector);
|
|
68
|
+
}
|
|
69
|
+
return (0, import_react.useStore)(pbmStore, (state) => state);
|
|
70
|
+
}
|
|
71
|
+
|
|
38
72
|
// src/components/Header/index.tsx
|
|
39
73
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
74
|
function Header({ originalProductPrice }) {
|
|
75
|
+
const { targetProduct } = usePBMStore();
|
|
76
|
+
const Price = targetProduct?.listPrice || originalProductPrice;
|
|
77
|
+
const Discount = Price * ((targetProduct?.discountMax || 0) / 100);
|
|
41
78
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
42
79
|
"header",
|
|
43
80
|
{
|
|
44
|
-
className: "flex items-center justify-between w-full p-0.5 rounded-full bg-[#44c2c0]/30",
|
|
81
|
+
className: "flex items-center justify-between w-full p-0.5 rounded-full bg-[#44c2c0]/30 mt-5",
|
|
45
82
|
id: "header_pbm",
|
|
46
83
|
children: [
|
|
47
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
48
85
|
"span",
|
|
49
86
|
{
|
|
50
|
-
className: "py-1 px-6 rounded-full bg-[#44c2c0] shrink-0 text-white text-
|
|
87
|
+
className: "py-1 px-6 rounded-full bg-[#44c2c0] shrink-0 text-white text-xl font-bold flex items-center justify-start gap-2 relative",
|
|
51
88
|
"data-testid": "test_id_header_price",
|
|
52
89
|
id: "header_price",
|
|
53
|
-
children:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "absolute -top-6 left-10 bg-emerald-500 px-4 py-1 rounded-t-2xl text-xs font-medium text-white", children: [
|
|
92
|
+
Discount.toLocaleString("pt-BR", {
|
|
93
|
+
currency: "BRL",
|
|
94
|
+
currencyDisplay: "symbol",
|
|
95
|
+
currencySign: "standard",
|
|
96
|
+
style: "currency"
|
|
97
|
+
}),
|
|
98
|
+
" OFF"
|
|
99
|
+
] }),
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "32px", height: "32px", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { id: "SVGRepo_iconCarrier", children: [
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 8.99998C10.5523 8.99998 11 9.44769 11 9.99998C11 10.5523 10.5523 11 10 11C9.44775 11 9.00004 10.5523 9.00004 9.99998C9.00004 9.44769 9.44775 8.99998 10 8.99998Z", fill: "#fff" }),
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 14C13 14.5523 13.4478 15 14 15C14.5523 15 15 14.5523 15 14C15 13.4477 14.5523 13 14 13C13.4478 13 13 13.4477 13 14Z", fill: "#fff" }),
|
|
106
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10.7071 14.7071L14.7071 10.7071C15.0977 10.3166 15.0977 9.6834 14.7071 9.29287C14.3166 8.90235 13.6835 8.90235 13.2929 9.29287L9.29293 13.2929C8.90241 13.6834 8.90241 14.3166 9.29293 14.7071C9.68346 15.0976 10.3166 15.0976 10.7071 14.7071Z", fill: "#fff" }),
|
|
107
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M16.3117 4.07145L15.1708 4.34503L14.5575 3.34485C13.3869 1.43575 10.6131 1.43575 9.44254 3.34485L8.82926 4.34503L7.68836 4.07145C5.51069 3.54925 3.54931 5.51063 4.07151 7.6883L4.34509 8.8292L3.34491 9.44248C1.43581 10.6131 1.43581 13.3869 3.34491 14.5575L4.34509 15.1708L4.07151 16.3117C3.54931 18.4893 5.51069 20.4507 7.68836 19.9285L8.82926 19.6549L9.44254 20.6551C10.6131 22.5642 13.3869 22.5642 14.5575 20.6551L15.1708 19.6549L16.3117 19.9285C18.4894 20.4507 20.4508 18.4893 19.9286 16.3117L19.655 15.1708L20.6552 14.5575C22.5643 13.3869 22.5643 10.6131 20.6552 9.44248L19.655 8.8292L19.9286 7.6883C20.4508 5.51063 18.4894 3.54925 16.3117 4.07145ZM11.1475 4.3903C11.5377 3.75393 12.4623 3.75393 12.8525 4.3903L13.8454 6.00951C14.0717 6.37867 14.51 6.56019 14.9311 6.45922L16.7781 6.01631C17.504 5.84225 18.1578 6.49604 17.9837 7.22193L17.5408 9.06894C17.4398 9.49003 17.6213 9.92827 17.9905 10.1546L19.6097 11.1475C20.2461 11.5377 20.2461 12.4623 19.6097 12.8525L17.9905 13.8453C17.6213 14.0717 17.4398 14.5099 17.5408 14.931L17.9837 16.778C18.1578 17.5039 17.504 18.1577 16.7781 17.9836L14.9311 17.5407C14.51 17.4398 14.0717 17.6213 13.8454 17.9904L12.8525 19.6097C12.4623 20.246 11.5377 20.246 11.1475 19.6097L10.1547 17.9904C9.92833 17.6213 9.49009 17.4398 9.069 17.5407L7.22199 17.9836C6.4961 18.1577 5.84231 17.5039 6.01637 16.778L6.45928 14.931C6.56026 14.5099 6.37873 14.0717 6.00957 13.8453L4.39036 12.8525C3.75399 12.4623 3.75399 11.5377 4.39036 11.1475L6.00957 10.1546C6.37873 9.92827 6.56026 9.49003 6.45928 9.06894L6.01637 7.22193C5.84231 6.49604 6.4961 5.84225 7.22199 6.01631L9.069 6.45922C9.49009 6.56019 9.92833 6.37867 10.1547 6.00951L11.1475 4.3903Z", fill: "#fff" })
|
|
108
|
+
] })
|
|
109
|
+
] }),
|
|
110
|
+
Number(Price - Discount)?.toLocaleString("pt-BR", {
|
|
111
|
+
currency: "BRL",
|
|
112
|
+
currencyDisplay: "symbol",
|
|
113
|
+
currencySign: "standard",
|
|
114
|
+
style: "currency"
|
|
115
|
+
})
|
|
116
|
+
]
|
|
59
117
|
}
|
|
60
118
|
),
|
|
61
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { id: "header_title", className: "text-center w-full text-[#339c9b] font-bold text-xs px-4 md:text-sm", children: "
|
|
119
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { id: "header_title", className: "text-center w-full text-[#339c9b] font-bold text-xs px-4 md:text-sm", children: "Desconto de Laborat\xF3rio" })
|
|
62
120
|
]
|
|
63
121
|
}
|
|
64
122
|
);
|
|
@@ -76,7 +134,7 @@ function Container({
|
|
|
76
134
|
"main",
|
|
77
135
|
{
|
|
78
136
|
className: (0, import_classnames.default)({
|
|
79
|
-
"flex flex-col items-center justify-center min-w-[var(--min-container)] max-w-[var(--max-container)] w-full h-auto rounded-2xl p-4 bg-gray-100 gap-4": variant === "main",
|
|
137
|
+
"border-3 border-[#44c2c0] flex flex-col items-center justify-center min-w-[var(--min-container)] max-w-[var(--max-container)] w-full h-auto rounded-2xl p-4 bg-gray-100 gap-4 relative": variant === "main",
|
|
80
138
|
"w-full h-auto relative": variant === "simple"
|
|
81
139
|
}),
|
|
82
140
|
"data-testid": "test_id_container",
|
|
@@ -92,38 +150,6 @@ var Container_default = Container;
|
|
|
92
150
|
var import_classnames2 = __toESM(require("classnames"));
|
|
93
151
|
var import_react2 = require("react");
|
|
94
152
|
|
|
95
|
-
// src/libs/zustand/usePBM.tsx
|
|
96
|
-
var import_zustand = require("zustand");
|
|
97
|
-
var import_react = require("zustand/react");
|
|
98
|
-
var initialPBMState = {
|
|
99
|
-
securityNumber: "",
|
|
100
|
-
state: "isEmpty",
|
|
101
|
-
availableDiscountSelected: {
|
|
102
|
-
quantity: 0,
|
|
103
|
-
discount: {
|
|
104
|
-
unit: 0,
|
|
105
|
-
total: 0
|
|
106
|
-
},
|
|
107
|
-
totalPrice: 0
|
|
108
|
-
},
|
|
109
|
-
targetProduct: null,
|
|
110
|
-
campaign: "pbm_campaign"
|
|
111
|
-
};
|
|
112
|
-
var createPBMStore = (set) => ({
|
|
113
|
-
...initialPBMState,
|
|
114
|
-
setSecurityNumber: (securityNumber) => set({ securityNumber }),
|
|
115
|
-
setState: (state) => set({ state }),
|
|
116
|
-
setTargetProduct: (targetProduct) => set({ targetProduct }),
|
|
117
|
-
setAvailableDiscountSelected: (availableDiscount) => set({ availableDiscountSelected: availableDiscount })
|
|
118
|
-
});
|
|
119
|
-
var pbmStore = (0, import_zustand.createStore)(createPBMStore);
|
|
120
|
-
function usePBMStore(selector) {
|
|
121
|
-
if (selector) {
|
|
122
|
-
return (0, import_react.useStore)(pbmStore, selector);
|
|
123
|
-
}
|
|
124
|
-
return (0, import_react.useStore)(pbmStore, (state) => state);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
153
|
// src/services/get-product-by-ean.ts
|
|
128
154
|
var import_js_cookie = __toESM(require("js-cookie"));
|
|
129
155
|
var import_meta = {};
|
|
@@ -151,7 +177,7 @@ var GetProductByEAN = async ({ PRODUCT_EAN }) => {
|
|
|
151
177
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
152
178
|
function Footer() {
|
|
153
179
|
const [industryLogo, setIndustryLogo] = (0, import_react2.useState)(null);
|
|
154
|
-
const { targetProduct, setTargetProduct } = usePBMStore();
|
|
180
|
+
const { targetProduct, setTargetProduct, state } = usePBMStore();
|
|
155
181
|
(0, import_react2.useEffect)(() => {
|
|
156
182
|
const fetchProductByEan = async () => {
|
|
157
183
|
if (!targetProduct?.ean) return;
|
|
@@ -162,7 +188,10 @@ function Footer() {
|
|
|
162
188
|
const { pbm, sku, ...targetProductNewData } = response.data;
|
|
163
189
|
setTargetProduct({
|
|
164
190
|
...targetProduct,
|
|
165
|
-
...targetProductNewData
|
|
191
|
+
...targetProductNewData,
|
|
192
|
+
productId: Number(targetProductNewData.productId),
|
|
193
|
+
informativeMessage: pbm.informativeMessage ?? "",
|
|
194
|
+
discountMax: pbm.discountMax ?? 0
|
|
166
195
|
});
|
|
167
196
|
}
|
|
168
197
|
} catch (error) {
|
|
@@ -171,23 +200,26 @@ function Footer() {
|
|
|
171
200
|
};
|
|
172
201
|
fetchProductByEan();
|
|
173
202
|
}, [targetProduct?.ean]);
|
|
174
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.
|
|
175
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "w-
|
|
176
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.
|
|
177
|
-
|
|
203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("footer", { className: "w-full h-auto relative", id: "footer_pbm", children: [
|
|
204
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: (0, import_classnames2.default)("flex items-center w-full h-auto gap-4", { "justify-center": industryLogo, "justify-start": !industryLogo }), children: [
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "w-4/5 h-auto", children: [
|
|
206
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "text-start font-semibold text-sm", children: "Economize com o benef\xEDcio do laborat\xF3rio." }),
|
|
207
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-start font-normal text-sm", children: "Este produto tem pre\xE7o exclusivo para clientes cadastrados no programa." })
|
|
208
|
+
] }),
|
|
209
|
+
industryLogo && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
210
|
+
"img",
|
|
211
|
+
{
|
|
212
|
+
src: industryLogo,
|
|
213
|
+
alt: "parceiro",
|
|
214
|
+
className: "w-1/5 min-w-20 h-auto aspect-auto rounded-xl",
|
|
215
|
+
loading: "eager",
|
|
216
|
+
id: "footer_industry_logo_pbm",
|
|
217
|
+
"data-testid": "footer_industry_logo_pbm"
|
|
218
|
+
}
|
|
219
|
+
)
|
|
178
220
|
] }),
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
{
|
|
182
|
-
src: industryLogo,
|
|
183
|
-
alt: "parceiro",
|
|
184
|
-
className: "w-1/5 min-w-20 h-auto aspect-auto",
|
|
185
|
-
loading: "eager",
|
|
186
|
-
id: "footer_industry_logo_pbm",
|
|
187
|
-
"data-testid": "footer_industry_logo_pbm"
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
] }) });
|
|
221
|
+
state !== "isActivated" && targetProduct?.informativeMessage && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-start font-semibold text-sm", children: targetProduct?.informativeMessage })
|
|
222
|
+
] });
|
|
191
223
|
}
|
|
192
224
|
var Footer_default = Footer;
|
|
193
225
|
|
|
@@ -221,10 +253,10 @@ var import_react_hook_form = require("react-hook-form");
|
|
|
221
253
|
var import_lucide_react = require("lucide-react");
|
|
222
254
|
var import_react3 = require("react");
|
|
223
255
|
|
|
224
|
-
// src/services/
|
|
256
|
+
// src/services/benefits-with-document.ts
|
|
225
257
|
var import_js_cookie2 = __toESM(require("js-cookie"));
|
|
226
258
|
var import_meta2 = {};
|
|
227
|
-
var
|
|
259
|
+
var BenefitsWithDocument = async ({ document: document2, products }) => {
|
|
228
260
|
const API_URL = import_meta2.env.VITE_API_URL;
|
|
229
261
|
if (!API_URL) {
|
|
230
262
|
throw new Error("API URL is not defined in environment variables");
|
|
@@ -233,13 +265,13 @@ var ValidateDocument = async ({ document, products }) => {
|
|
|
233
265
|
if (!AUTH_TOKEN) {
|
|
234
266
|
throw new Error("Token is not defined in cookies or is expired");
|
|
235
267
|
}
|
|
236
|
-
const response = await fetch(`${API_URL}/
|
|
268
|
+
const response = await fetch(`${API_URL}/products/benefitByDocument`, {
|
|
237
269
|
method: "POST",
|
|
238
270
|
headers: {
|
|
239
271
|
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
240
272
|
"Content-Type": "application/json"
|
|
241
273
|
},
|
|
242
|
-
body: JSON.stringify({ document, products })
|
|
274
|
+
body: JSON.stringify({ consumer: { document: document2 }, products })
|
|
243
275
|
});
|
|
244
276
|
const dataResponse = await response.json();
|
|
245
277
|
if (!dataResponse.success) {
|
|
@@ -257,7 +289,7 @@ function Button(props) {
|
|
|
257
289
|
{
|
|
258
290
|
...props,
|
|
259
291
|
className: (0, import_classnames3.default)(
|
|
260
|
-
"w-3xs cursor-pointer h-10 rounded-full bg-
|
|
292
|
+
"w-3xs cursor-pointer h-10 rounded-full bg-emerald-500 hover:bg-emerald-400 text-white text-sm font-semibold transition-colors",
|
|
261
293
|
props.className
|
|
262
294
|
),
|
|
263
295
|
children: props.children
|
|
@@ -269,7 +301,7 @@ var Button_default = Button;
|
|
|
269
301
|
// src/components/Form/index.tsx
|
|
270
302
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
271
303
|
function Form({ setLoading }) {
|
|
272
|
-
const { setSecurityNumber, setState, securityNumber, targetProduct } = usePBMStore();
|
|
304
|
+
const { setSecurityNumber, setState, securityNumber, targetProduct, setUrlAcceptTerms, setUrlRegisterIndustry } = usePBMStore();
|
|
273
305
|
const [showCoupoField, setShowCoupoField] = (0, import_react3.useState)(false);
|
|
274
306
|
const {
|
|
275
307
|
handleSubmit,
|
|
@@ -296,17 +328,40 @@ function Form({ setLoading }) {
|
|
|
296
328
|
console.error("PBMLOG: Product is not defined!");
|
|
297
329
|
return;
|
|
298
330
|
}
|
|
299
|
-
|
|
331
|
+
if (!targetProduct.productId) {
|
|
332
|
+
console.error("PBMLOG: Product ID is not defined!");
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (!targetProduct.listPrice) {
|
|
336
|
+
console.error("PBMLOG: List Price is not defined!");
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
const response = await BenefitsWithDocument({
|
|
300
340
|
document: values.securityNumber.replace(/\D/g, ""),
|
|
301
|
-
products: [{
|
|
341
|
+
products: [{
|
|
342
|
+
productId: targetProduct.productId,
|
|
343
|
+
ean: targetProduct.ean,
|
|
344
|
+
requestedQuantity: 1,
|
|
345
|
+
listPrice: targetProduct.listPrice,
|
|
346
|
+
netPrice: targetProduct.netPrice ?? targetProduct.listPrice
|
|
347
|
+
}]
|
|
302
348
|
});
|
|
303
349
|
if (response.success) {
|
|
304
350
|
const status = {
|
|
305
|
-
"
|
|
306
|
-
"
|
|
351
|
+
"acceptance": "isInvalid",
|
|
352
|
+
"industry registration": "isRegistered",
|
|
353
|
+
"active": "isActivated"
|
|
307
354
|
};
|
|
308
355
|
setSecurityNumber(values.securityNumber);
|
|
309
|
-
setState(status[response.data.
|
|
356
|
+
setState(status[response.data.product[0].statusCustomer]);
|
|
357
|
+
if (status[response.data.product[0].statusCustomer] === "isInvalid") {
|
|
358
|
+
setUrlAcceptTerms(response.data.product[0].urlAcceptTerm || void 0);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (status[response.data.product[0].statusCustomer] === "isRegistered") {
|
|
362
|
+
setUrlRegisterIndustry(response.data.product[0].informativeLink);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
310
365
|
}
|
|
311
366
|
} catch (error) {
|
|
312
367
|
console.error("PBMLOG: Error validating document -", error);
|
|
@@ -338,7 +393,7 @@ function Form({ setLoading }) {
|
|
|
338
393
|
{
|
|
339
394
|
type: "text",
|
|
340
395
|
className: (0, import_classnames4.default)(
|
|
341
|
-
"w-full h-8 bg-
|
|
396
|
+
"w-full h-8 bg-white rounded-s-full text-sm font-semibold focus:outline focus:outline-[#339c9b] focus:bg-white text-zinc-600 placeholder:text-zinc-600 px-4 placeholder:text-sm placeholder:font-semibold",
|
|
342
397
|
{ "outline outline-red-600": errors.securityNumber, "rounded-full": showCoupoField }
|
|
343
398
|
),
|
|
344
399
|
placeholder: "Digite seu CPF aqui...",
|
|
@@ -397,7 +452,7 @@ function Form({ setLoading }) {
|
|
|
397
452
|
{
|
|
398
453
|
type: "submit",
|
|
399
454
|
className: (0, import_classnames4.default)(
|
|
400
|
-
"bg-
|
|
455
|
+
"bg-emerald-500 w-1/5 h-8 flex items-center justify-center rounded-e-full cursor-pointer",
|
|
401
456
|
{ "rounded-full": showCoupoField }
|
|
402
457
|
),
|
|
403
458
|
id: "button_submit_security_number_pbm",
|
|
@@ -739,8 +794,38 @@ var Text_default = Text;
|
|
|
739
794
|
// src/components/Iframe/index.tsx
|
|
740
795
|
var import_classnames7 = __toESM(require("classnames"));
|
|
741
796
|
var import_lucide_react3 = require("lucide-react");
|
|
797
|
+
var import_react6 = require("react");
|
|
742
798
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
743
799
|
function Iframe({ url, title, openModal, setOpenModal }) {
|
|
800
|
+
const [_, setIframeError] = (0, import_react6.useState)(false);
|
|
801
|
+
const [showFallback, setShowFallback] = (0, import_react6.useState)(false);
|
|
802
|
+
(0, import_react6.useEffect)(() => {
|
|
803
|
+
if (openModal && url) {
|
|
804
|
+
setIframeError(false);
|
|
805
|
+
setShowFallback(false);
|
|
806
|
+
const timeout = setTimeout(() => {
|
|
807
|
+
const iframe = document.querySelector('iframe[src="' + url + '"]');
|
|
808
|
+
if (iframe) {
|
|
809
|
+
try {
|
|
810
|
+
const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
811
|
+
if (!iframeDoc) {
|
|
812
|
+
setIframeError(true);
|
|
813
|
+
setShowFallback(true);
|
|
814
|
+
}
|
|
815
|
+
} catch (e) {
|
|
816
|
+
setIframeError(true);
|
|
817
|
+
setShowFallback(true);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}, 2e3);
|
|
821
|
+
return () => clearTimeout(timeout);
|
|
822
|
+
}
|
|
823
|
+
}, [openModal, url]);
|
|
824
|
+
const handleOpenInNewWindow = () => {
|
|
825
|
+
if (url) {
|
|
826
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
827
|
+
}
|
|
828
|
+
};
|
|
744
829
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
745
830
|
"main",
|
|
746
831
|
{
|
|
@@ -777,7 +862,22 @@ function Iframe({ url, title, openModal, setOpenModal }) {
|
|
|
777
862
|
children: "Fechar"
|
|
778
863
|
}
|
|
779
864
|
) }),
|
|
780
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.
|
|
865
|
+
showFallback ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "w-4/5 h-[80%] bg-zinc-800 z-10 flex flex-col items-center justify-center p-8 rounded-lg border-2 border-yellow-500", children: [
|
|
866
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.TriangleAlert, { size: 48, className: "text-yellow-500 mb-4" }),
|
|
867
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: "text-white text-xl font-bold mb-4 text-center", children: "N\xE3o foi poss\xEDvel carregar o conte\xFAdo" }),
|
|
868
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-white text-sm mb-6 text-center max-w-md", children: "O servidor bloqueou a exibi\xE7\xE3o deste conte\xFAdo em um iframe devido \xE0s pol\xEDticas de seguran\xE7a. Voc\xEA pode abrir o link em uma nova janela para continuar." }),
|
|
869
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
870
|
+
"button",
|
|
871
|
+
{
|
|
872
|
+
onClick: handleOpenInNewWindow,
|
|
873
|
+
className: "flex items-center gap-2 bg-emerald-500 hover:bg-emerald-600 text-white font-semibold px-6 py-3 rounded-lg transition-colors",
|
|
874
|
+
children: [
|
|
875
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.ExternalLink, { size: 20 }),
|
|
876
|
+
"Abrir em nova janela"
|
|
877
|
+
]
|
|
878
|
+
}
|
|
879
|
+
)
|
|
880
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
781
881
|
"iframe",
|
|
782
882
|
{
|
|
783
883
|
src: url,
|
|
@@ -785,7 +885,11 @@ function Iframe({ url, title, openModal, setOpenModal }) {
|
|
|
785
885
|
width: "80%",
|
|
786
886
|
height: "80%",
|
|
787
887
|
allowFullScreen: true,
|
|
788
|
-
className: "z-10"
|
|
888
|
+
className: "z-10",
|
|
889
|
+
onError: () => {
|
|
890
|
+
setIframeError(true);
|
|
891
|
+
setShowFallback(true);
|
|
892
|
+
}
|
|
789
893
|
}
|
|
790
894
|
),
|
|
791
895
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { className: "items-center justify-center flex flex-wrap gap-1 bg-zinc-800 z-10 w-4/5 py-2 px-4 rounded-ee-2xl rounded-es-2xl border-t-2 border-gray-100", children: [
|
|
@@ -804,10 +908,11 @@ function Iframe({ url, title, openModal, setOpenModal }) {
|
|
|
804
908
|
var Iframe_default = Iframe;
|
|
805
909
|
|
|
806
910
|
// src/components/SecurityNumberInvalid/index.tsx
|
|
807
|
-
var
|
|
911
|
+
var import_react7 = require("react");
|
|
808
912
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
809
913
|
function SecurityNumberInvalid({ textColor }) {
|
|
810
|
-
const [openModal, setOpenModal] = (0,
|
|
914
|
+
const [openModal, setOpenModal] = (0, import_react7.useState)(false);
|
|
915
|
+
const { urlAcceptTerms } = usePBMStore();
|
|
811
916
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
812
917
|
"section",
|
|
813
918
|
{
|
|
@@ -829,7 +934,7 @@ function SecurityNumberInvalid({ textColor }) {
|
|
|
829
934
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
830
935
|
Iframe_default,
|
|
831
936
|
{
|
|
832
|
-
url: "
|
|
937
|
+
url: urlAcceptTerms || "",
|
|
833
938
|
title: "Aceitar termos PBM",
|
|
834
939
|
openModal,
|
|
835
940
|
setOpenModal
|
|
@@ -842,7 +947,7 @@ function SecurityNumberInvalid({ textColor }) {
|
|
|
842
947
|
var SecurityNumberInvalid_default = SecurityNumberInvalid;
|
|
843
948
|
|
|
844
949
|
// src/PBM.tsx
|
|
845
|
-
var
|
|
950
|
+
var import_react8 = require("react");
|
|
846
951
|
|
|
847
952
|
// src/components/UI/Link/index.tsx
|
|
848
953
|
var import_classnames8 = __toESM(require("classnames"));
|
|
@@ -863,7 +968,7 @@ function Link(props) {
|
|
|
863
968
|
target: "_blank",
|
|
864
969
|
href: typeof props.href === "string" ? props.href : props.href.pathname + getParams(props.href.param),
|
|
865
970
|
className: (0, import_classnames8.default)(
|
|
866
|
-
"w-3xs cursor-pointer h-10 rounded-full bg-
|
|
971
|
+
"w-3xs cursor-pointer h-10 rounded-full bg-emerald-500 hover:bg-emerald-400 text-white text-sm font-semibold transition-colors flex items-center justify-center",
|
|
867
972
|
props.className
|
|
868
973
|
),
|
|
869
974
|
"data-testid": "test_id_link",
|
|
@@ -877,6 +982,7 @@ var Link_default = Link;
|
|
|
877
982
|
// src/components/SecurityNumberRegitered/index.tsx
|
|
878
983
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
879
984
|
function SecurityNumberRegitered({ textColor }) {
|
|
985
|
+
const { urlRegisterIndustry } = usePBMStore();
|
|
880
986
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
881
987
|
"section",
|
|
882
988
|
{
|
|
@@ -889,10 +995,7 @@ function SecurityNumberRegitered({ textColor }) {
|
|
|
889
995
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
890
996
|
Link_default,
|
|
891
997
|
{
|
|
892
|
-
href:
|
|
893
|
-
pathname: "https://gip-pd-app.interplayers.com.br/idp-pd-app/adesao",
|
|
894
|
-
param: { guid: "f2aff249-51b4-49a4-b671-d6bee89da0f0" }
|
|
895
|
-
},
|
|
998
|
+
href: urlRegisterIndustry || "",
|
|
896
999
|
children: "Ativar CPF"
|
|
897
1000
|
}
|
|
898
1001
|
)
|
|
@@ -954,14 +1057,14 @@ function PBM({
|
|
|
954
1057
|
const formatedOriginalProductPrice = Number(
|
|
955
1058
|
String(originalProductPrice).replace(",", ".")
|
|
956
1059
|
);
|
|
957
|
-
const [loading, setLoading] = (0,
|
|
1060
|
+
const [loading, setLoading] = (0, import_react8.useState)(false);
|
|
958
1061
|
const { setState, state, setTargetProduct } = usePBMStore();
|
|
959
|
-
(0,
|
|
1062
|
+
(0, import_react8.useEffect)(() => {
|
|
960
1063
|
if (eanProduct) {
|
|
961
1064
|
setTargetProduct({ ean: eanProduct });
|
|
962
1065
|
}
|
|
963
1066
|
}, [eanProduct, setTargetProduct]);
|
|
964
|
-
const handleAuthorizationRequest = (0,
|
|
1067
|
+
const handleAuthorizationRequest = (0, import_react8.useCallback)(async () => {
|
|
965
1068
|
try {
|
|
966
1069
|
const response = await GetAuthorization({ clientID });
|
|
967
1070
|
if (!response.success) {
|
|
@@ -971,7 +1074,7 @@ function PBM({
|
|
|
971
1074
|
console.error("Error fetching authorization:", error);
|
|
972
1075
|
}
|
|
973
1076
|
}, [clientID]);
|
|
974
|
-
(0,
|
|
1077
|
+
(0, import_react8.useEffect)(() => {
|
|
975
1078
|
handleAuthorizationRequest();
|
|
976
1079
|
}, [handleAuthorizationRequest]);
|
|
977
1080
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Container_default, { variant: "main", children: [
|