@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.mjs
CHANGED
|
@@ -1,27 +1,85 @@
|
|
|
1
|
+
// src/libs/zustand/usePBM.tsx
|
|
2
|
+
import { createStore } from "zustand";
|
|
3
|
+
import { useStore } from "zustand/react";
|
|
4
|
+
var initialPBMState = {
|
|
5
|
+
securityNumber: "",
|
|
6
|
+
state: "isEmpty",
|
|
7
|
+
availableDiscountSelected: {
|
|
8
|
+
quantity: 0,
|
|
9
|
+
discount: {
|
|
10
|
+
unit: 0,
|
|
11
|
+
total: 0
|
|
12
|
+
},
|
|
13
|
+
totalPrice: 0
|
|
14
|
+
},
|
|
15
|
+
targetProduct: null,
|
|
16
|
+
campaign: "pbm_campaign"
|
|
17
|
+
};
|
|
18
|
+
var createPBMStore = (set) => ({
|
|
19
|
+
...initialPBMState,
|
|
20
|
+
setSecurityNumber: (securityNumber) => set({ securityNumber }),
|
|
21
|
+
setState: (state) => set({ state }),
|
|
22
|
+
setTargetProduct: (targetProduct) => set({ targetProduct }),
|
|
23
|
+
setAvailableDiscountSelected: (availableDiscount) => set({ availableDiscountSelected: availableDiscount }),
|
|
24
|
+
setUrlAcceptTerms: (urlAcceptTerms) => set({ urlAcceptTerms }),
|
|
25
|
+
setUrlRegisterIndustry: (urlRegisterIndustry) => set({ urlRegisterIndustry })
|
|
26
|
+
});
|
|
27
|
+
var pbmStore = createStore(createPBMStore);
|
|
28
|
+
function usePBMStore(selector) {
|
|
29
|
+
if (selector) {
|
|
30
|
+
return useStore(pbmStore, selector);
|
|
31
|
+
}
|
|
32
|
+
return useStore(pbmStore, (state) => state);
|
|
33
|
+
}
|
|
34
|
+
|
|
1
35
|
// src/components/Header/index.tsx
|
|
2
36
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
37
|
function Header({ originalProductPrice }) {
|
|
38
|
+
const { targetProduct } = usePBMStore();
|
|
39
|
+
const Price = targetProduct?.listPrice || originalProductPrice;
|
|
40
|
+
const Discount = Price * ((targetProduct?.discountMax || 0) / 100);
|
|
4
41
|
return /* @__PURE__ */ jsxs(
|
|
5
42
|
"header",
|
|
6
43
|
{
|
|
7
|
-
className: "flex items-center justify-between w-full p-0.5 rounded-full bg-[#44c2c0]/30",
|
|
44
|
+
className: "flex items-center justify-between w-full p-0.5 rounded-full bg-[#44c2c0]/30 mt-5",
|
|
8
45
|
id: "header_pbm",
|
|
9
46
|
children: [
|
|
10
|
-
/* @__PURE__ */
|
|
47
|
+
/* @__PURE__ */ jsxs(
|
|
11
48
|
"span",
|
|
12
49
|
{
|
|
13
|
-
className: "py-1 px-6 rounded-full bg-[#44c2c0] shrink-0 text-white text-
|
|
50
|
+
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",
|
|
14
51
|
"data-testid": "test_id_header_price",
|
|
15
52
|
id: "header_price",
|
|
16
|
-
children:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ 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: [
|
|
55
|
+
Discount.toLocaleString("pt-BR", {
|
|
56
|
+
currency: "BRL",
|
|
57
|
+
currencyDisplay: "symbol",
|
|
58
|
+
currencySign: "standard",
|
|
59
|
+
style: "currency"
|
|
60
|
+
}),
|
|
61
|
+
" OFF"
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsxs("svg", { width: "32px", height: "32px", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
64
|
+
/* @__PURE__ */ jsx("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
65
|
+
/* @__PURE__ */ jsx("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
66
|
+
/* @__PURE__ */ jsxs("g", { id: "SVGRepo_iconCarrier", children: [
|
|
67
|
+
/* @__PURE__ */ 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" }),
|
|
68
|
+
/* @__PURE__ */ 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" }),
|
|
69
|
+
/* @__PURE__ */ 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" }),
|
|
70
|
+
/* @__PURE__ */ 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" })
|
|
71
|
+
] })
|
|
72
|
+
] }),
|
|
73
|
+
Number(Price - Discount)?.toLocaleString("pt-BR", {
|
|
74
|
+
currency: "BRL",
|
|
75
|
+
currencyDisplay: "symbol",
|
|
76
|
+
currencySign: "standard",
|
|
77
|
+
style: "currency"
|
|
78
|
+
})
|
|
79
|
+
]
|
|
22
80
|
}
|
|
23
81
|
),
|
|
24
|
-
/* @__PURE__ */ jsx("h1", { id: "header_title", className: "text-center w-full text-[#339c9b] font-bold text-xs px-4 md:text-sm", children: "
|
|
82
|
+
/* @__PURE__ */ 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" })
|
|
25
83
|
]
|
|
26
84
|
}
|
|
27
85
|
);
|
|
@@ -39,7 +97,7 @@ function Container({
|
|
|
39
97
|
"main",
|
|
40
98
|
{
|
|
41
99
|
className: classNames({
|
|
42
|
-
"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",
|
|
100
|
+
"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",
|
|
43
101
|
"w-full h-auto relative": variant === "simple"
|
|
44
102
|
}),
|
|
45
103
|
"data-testid": "test_id_container",
|
|
@@ -55,38 +113,6 @@ var Container_default = Container;
|
|
|
55
113
|
import classNames2 from "classnames";
|
|
56
114
|
import { useEffect, useState } from "react";
|
|
57
115
|
|
|
58
|
-
// src/libs/zustand/usePBM.tsx
|
|
59
|
-
import { createStore } from "zustand";
|
|
60
|
-
import { useStore } from "zustand/react";
|
|
61
|
-
var initialPBMState = {
|
|
62
|
-
securityNumber: "",
|
|
63
|
-
state: "isEmpty",
|
|
64
|
-
availableDiscountSelected: {
|
|
65
|
-
quantity: 0,
|
|
66
|
-
discount: {
|
|
67
|
-
unit: 0,
|
|
68
|
-
total: 0
|
|
69
|
-
},
|
|
70
|
-
totalPrice: 0
|
|
71
|
-
},
|
|
72
|
-
targetProduct: null,
|
|
73
|
-
campaign: "pbm_campaign"
|
|
74
|
-
};
|
|
75
|
-
var createPBMStore = (set) => ({
|
|
76
|
-
...initialPBMState,
|
|
77
|
-
setSecurityNumber: (securityNumber) => set({ securityNumber }),
|
|
78
|
-
setState: (state) => set({ state }),
|
|
79
|
-
setTargetProduct: (targetProduct) => set({ targetProduct }),
|
|
80
|
-
setAvailableDiscountSelected: (availableDiscount) => set({ availableDiscountSelected: availableDiscount })
|
|
81
|
-
});
|
|
82
|
-
var pbmStore = createStore(createPBMStore);
|
|
83
|
-
function usePBMStore(selector) {
|
|
84
|
-
if (selector) {
|
|
85
|
-
return useStore(pbmStore, selector);
|
|
86
|
-
}
|
|
87
|
-
return useStore(pbmStore, (state) => state);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
116
|
// src/services/get-product-by-ean.ts
|
|
91
117
|
import Cookies from "js-cookie";
|
|
92
118
|
var GetProductByEAN = async ({ PRODUCT_EAN }) => {
|
|
@@ -113,7 +139,7 @@ var GetProductByEAN = async ({ PRODUCT_EAN }) => {
|
|
|
113
139
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
114
140
|
function Footer() {
|
|
115
141
|
const [industryLogo, setIndustryLogo] = useState(null);
|
|
116
|
-
const { targetProduct, setTargetProduct } = usePBMStore();
|
|
142
|
+
const { targetProduct, setTargetProduct, state } = usePBMStore();
|
|
117
143
|
useEffect(() => {
|
|
118
144
|
const fetchProductByEan = async () => {
|
|
119
145
|
if (!targetProduct?.ean) return;
|
|
@@ -124,7 +150,10 @@ function Footer() {
|
|
|
124
150
|
const { pbm, sku, ...targetProductNewData } = response.data;
|
|
125
151
|
setTargetProduct({
|
|
126
152
|
...targetProduct,
|
|
127
|
-
...targetProductNewData
|
|
153
|
+
...targetProductNewData,
|
|
154
|
+
productId: Number(targetProductNewData.productId),
|
|
155
|
+
informativeMessage: pbm.informativeMessage ?? "",
|
|
156
|
+
discountMax: pbm.discountMax ?? 0
|
|
128
157
|
});
|
|
129
158
|
}
|
|
130
159
|
} catch (error) {
|
|
@@ -133,23 +162,26 @@ function Footer() {
|
|
|
133
162
|
};
|
|
134
163
|
fetchProductByEan();
|
|
135
164
|
}, [targetProduct?.ean]);
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */ jsxs2("section", { className: "w-
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
|
|
165
|
+
return /* @__PURE__ */ jsxs2("footer", { className: "w-full h-auto relative", id: "footer_pbm", children: [
|
|
166
|
+
/* @__PURE__ */ jsxs2("section", { className: classNames2("flex items-center w-full h-auto gap-4", { "justify-center": industryLogo, "justify-start": !industryLogo }), children: [
|
|
167
|
+
/* @__PURE__ */ jsxs2("section", { className: "w-4/5 h-auto", children: [
|
|
168
|
+
/* @__PURE__ */ jsx3("h3", { className: "text-start font-semibold text-sm", children: "Economize com o benef\xEDcio do laborat\xF3rio." }),
|
|
169
|
+
/* @__PURE__ */ jsx3("p", { className: "text-start font-normal text-sm", children: "Este produto tem pre\xE7o exclusivo para clientes cadastrados no programa." })
|
|
170
|
+
] }),
|
|
171
|
+
industryLogo && /* @__PURE__ */ jsx3(
|
|
172
|
+
"img",
|
|
173
|
+
{
|
|
174
|
+
src: industryLogo,
|
|
175
|
+
alt: "parceiro",
|
|
176
|
+
className: "w-1/5 min-w-20 h-auto aspect-auto rounded-xl",
|
|
177
|
+
loading: "eager",
|
|
178
|
+
id: "footer_industry_logo_pbm",
|
|
179
|
+
"data-testid": "footer_industry_logo_pbm"
|
|
180
|
+
}
|
|
181
|
+
)
|
|
140
182
|
] }),
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
{
|
|
144
|
-
src: industryLogo,
|
|
145
|
-
alt: "parceiro",
|
|
146
|
-
className: "w-1/5 min-w-20 h-auto aspect-auto",
|
|
147
|
-
loading: "eager",
|
|
148
|
-
id: "footer_industry_logo_pbm",
|
|
149
|
-
"data-testid": "footer_industry_logo_pbm"
|
|
150
|
-
}
|
|
151
|
-
)
|
|
152
|
-
] }) });
|
|
183
|
+
state !== "isActivated" && targetProduct?.informativeMessage && /* @__PURE__ */ jsx3("p", { className: "text-start font-semibold text-sm", children: targetProduct?.informativeMessage })
|
|
184
|
+
] });
|
|
153
185
|
}
|
|
154
186
|
var Footer_default = Footer;
|
|
155
187
|
|
|
@@ -183,9 +215,9 @@ import { useForm } from "react-hook-form";
|
|
|
183
215
|
import { ArrowRight } from "lucide-react";
|
|
184
216
|
import { useState as useState2 } from "react";
|
|
185
217
|
|
|
186
|
-
// src/services/
|
|
218
|
+
// src/services/benefits-with-document.ts
|
|
187
219
|
import Cookies2 from "js-cookie";
|
|
188
|
-
var
|
|
220
|
+
var BenefitsWithDocument = async ({ document: document2, products }) => {
|
|
189
221
|
const API_URL = import.meta.env.VITE_API_URL;
|
|
190
222
|
if (!API_URL) {
|
|
191
223
|
throw new Error("API URL is not defined in environment variables");
|
|
@@ -194,13 +226,13 @@ var ValidateDocument = async ({ document, products }) => {
|
|
|
194
226
|
if (!AUTH_TOKEN) {
|
|
195
227
|
throw new Error("Token is not defined in cookies or is expired");
|
|
196
228
|
}
|
|
197
|
-
const response = await fetch(`${API_URL}/
|
|
229
|
+
const response = await fetch(`${API_URL}/products/benefitByDocument`, {
|
|
198
230
|
method: "POST",
|
|
199
231
|
headers: {
|
|
200
232
|
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
201
233
|
"Content-Type": "application/json"
|
|
202
234
|
},
|
|
203
|
-
body: JSON.stringify({ document, products })
|
|
235
|
+
body: JSON.stringify({ consumer: { document: document2 }, products })
|
|
204
236
|
});
|
|
205
237
|
const dataResponse = await response.json();
|
|
206
238
|
if (!dataResponse.success) {
|
|
@@ -218,7 +250,7 @@ function Button(props) {
|
|
|
218
250
|
{
|
|
219
251
|
...props,
|
|
220
252
|
className: classNames3(
|
|
221
|
-
"w-3xs cursor-pointer h-10 rounded-full bg-
|
|
253
|
+
"w-3xs cursor-pointer h-10 rounded-full bg-emerald-500 hover:bg-emerald-400 text-white text-sm font-semibold transition-colors",
|
|
222
254
|
props.className
|
|
223
255
|
),
|
|
224
256
|
children: props.children
|
|
@@ -230,7 +262,7 @@ var Button_default = Button;
|
|
|
230
262
|
// src/components/Form/index.tsx
|
|
231
263
|
import { Fragment, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
232
264
|
function Form({ setLoading }) {
|
|
233
|
-
const { setSecurityNumber, setState, securityNumber, targetProduct } = usePBMStore();
|
|
265
|
+
const { setSecurityNumber, setState, securityNumber, targetProduct, setUrlAcceptTerms, setUrlRegisterIndustry } = usePBMStore();
|
|
234
266
|
const [showCoupoField, setShowCoupoField] = useState2(false);
|
|
235
267
|
const {
|
|
236
268
|
handleSubmit,
|
|
@@ -257,17 +289,40 @@ function Form({ setLoading }) {
|
|
|
257
289
|
console.error("PBMLOG: Product is not defined!");
|
|
258
290
|
return;
|
|
259
291
|
}
|
|
260
|
-
|
|
292
|
+
if (!targetProduct.productId) {
|
|
293
|
+
console.error("PBMLOG: Product ID is not defined!");
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (!targetProduct.listPrice) {
|
|
297
|
+
console.error("PBMLOG: List Price is not defined!");
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const response = await BenefitsWithDocument({
|
|
261
301
|
document: values.securityNumber.replace(/\D/g, ""),
|
|
262
|
-
products: [{
|
|
302
|
+
products: [{
|
|
303
|
+
productId: targetProduct.productId,
|
|
304
|
+
ean: targetProduct.ean,
|
|
305
|
+
requestedQuantity: 1,
|
|
306
|
+
listPrice: targetProduct.listPrice,
|
|
307
|
+
netPrice: targetProduct.netPrice ?? targetProduct.listPrice
|
|
308
|
+
}]
|
|
263
309
|
});
|
|
264
310
|
if (response.success) {
|
|
265
311
|
const status = {
|
|
266
|
-
"
|
|
267
|
-
"
|
|
312
|
+
"acceptance": "isInvalid",
|
|
313
|
+
"industry registration": "isRegistered",
|
|
314
|
+
"active": "isActivated"
|
|
268
315
|
};
|
|
269
316
|
setSecurityNumber(values.securityNumber);
|
|
270
|
-
setState(status[response.data.
|
|
317
|
+
setState(status[response.data.product[0].statusCustomer]);
|
|
318
|
+
if (status[response.data.product[0].statusCustomer] === "isInvalid") {
|
|
319
|
+
setUrlAcceptTerms(response.data.product[0].urlAcceptTerm || void 0);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (status[response.data.product[0].statusCustomer] === "isRegistered") {
|
|
323
|
+
setUrlRegisterIndustry(response.data.product[0].informativeLink);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
271
326
|
}
|
|
272
327
|
} catch (error) {
|
|
273
328
|
console.error("PBMLOG: Error validating document -", error);
|
|
@@ -299,7 +354,7 @@ function Form({ setLoading }) {
|
|
|
299
354
|
{
|
|
300
355
|
type: "text",
|
|
301
356
|
className: classNames4(
|
|
302
|
-
"w-full h-8 bg-
|
|
357
|
+
"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",
|
|
303
358
|
{ "outline outline-red-600": errors.securityNumber, "rounded-full": showCoupoField }
|
|
304
359
|
),
|
|
305
360
|
placeholder: "Digite seu CPF aqui...",
|
|
@@ -358,7 +413,7 @@ function Form({ setLoading }) {
|
|
|
358
413
|
{
|
|
359
414
|
type: "submit",
|
|
360
415
|
className: classNames4(
|
|
361
|
-
"bg-
|
|
416
|
+
"bg-emerald-500 w-1/5 h-8 flex items-center justify-center rounded-e-full cursor-pointer",
|
|
362
417
|
{ "rounded-full": showCoupoField }
|
|
363
418
|
),
|
|
364
419
|
id: "button_submit_security_number_pbm",
|
|
@@ -698,9 +753,39 @@ var Text_default = Text;
|
|
|
698
753
|
|
|
699
754
|
// src/components/Iframe/index.tsx
|
|
700
755
|
import classNames7 from "classnames";
|
|
701
|
-
import { TriangleAlert } from "lucide-react";
|
|
756
|
+
import { TriangleAlert, ExternalLink } from "lucide-react";
|
|
757
|
+
import { useState as useState4, useEffect as useEffect4 } from "react";
|
|
702
758
|
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
703
759
|
function Iframe({ url, title, openModal, setOpenModal }) {
|
|
760
|
+
const [_, setIframeError] = useState4(false);
|
|
761
|
+
const [showFallback, setShowFallback] = useState4(false);
|
|
762
|
+
useEffect4(() => {
|
|
763
|
+
if (openModal && url) {
|
|
764
|
+
setIframeError(false);
|
|
765
|
+
setShowFallback(false);
|
|
766
|
+
const timeout = setTimeout(() => {
|
|
767
|
+
const iframe = document.querySelector('iframe[src="' + url + '"]');
|
|
768
|
+
if (iframe) {
|
|
769
|
+
try {
|
|
770
|
+
const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
771
|
+
if (!iframeDoc) {
|
|
772
|
+
setIframeError(true);
|
|
773
|
+
setShowFallback(true);
|
|
774
|
+
}
|
|
775
|
+
} catch (e) {
|
|
776
|
+
setIframeError(true);
|
|
777
|
+
setShowFallback(true);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}, 2e3);
|
|
781
|
+
return () => clearTimeout(timeout);
|
|
782
|
+
}
|
|
783
|
+
}, [openModal, url]);
|
|
784
|
+
const handleOpenInNewWindow = () => {
|
|
785
|
+
if (url) {
|
|
786
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
787
|
+
}
|
|
788
|
+
};
|
|
704
789
|
return /* @__PURE__ */ jsxs7(
|
|
705
790
|
"main",
|
|
706
791
|
{
|
|
@@ -737,7 +822,22 @@ function Iframe({ url, title, openModal, setOpenModal }) {
|
|
|
737
822
|
children: "Fechar"
|
|
738
823
|
}
|
|
739
824
|
) }),
|
|
740
|
-
/* @__PURE__ */
|
|
825
|
+
showFallback ? /* @__PURE__ */ jsxs7("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: [
|
|
826
|
+
/* @__PURE__ */ jsx11(TriangleAlert, { size: 48, className: "text-yellow-500 mb-4" }),
|
|
827
|
+
/* @__PURE__ */ jsx11("h3", { className: "text-white text-xl font-bold mb-4 text-center", children: "N\xE3o foi poss\xEDvel carregar o conte\xFAdo" }),
|
|
828
|
+
/* @__PURE__ */ jsx11("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." }),
|
|
829
|
+
/* @__PURE__ */ jsxs7(
|
|
830
|
+
"button",
|
|
831
|
+
{
|
|
832
|
+
onClick: handleOpenInNewWindow,
|
|
833
|
+
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",
|
|
834
|
+
children: [
|
|
835
|
+
/* @__PURE__ */ jsx11(ExternalLink, { size: 20 }),
|
|
836
|
+
"Abrir em nova janela"
|
|
837
|
+
]
|
|
838
|
+
}
|
|
839
|
+
)
|
|
840
|
+
] }) : /* @__PURE__ */ jsx11(
|
|
741
841
|
"iframe",
|
|
742
842
|
{
|
|
743
843
|
src: url,
|
|
@@ -745,7 +845,11 @@ function Iframe({ url, title, openModal, setOpenModal }) {
|
|
|
745
845
|
width: "80%",
|
|
746
846
|
height: "80%",
|
|
747
847
|
allowFullScreen: true,
|
|
748
|
-
className: "z-10"
|
|
848
|
+
className: "z-10",
|
|
849
|
+
onError: () => {
|
|
850
|
+
setIframeError(true);
|
|
851
|
+
setShowFallback(true);
|
|
852
|
+
}
|
|
749
853
|
}
|
|
750
854
|
),
|
|
751
855
|
/* @__PURE__ */ jsxs7("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: [
|
|
@@ -764,10 +868,11 @@ function Iframe({ url, title, openModal, setOpenModal }) {
|
|
|
764
868
|
var Iframe_default = Iframe;
|
|
765
869
|
|
|
766
870
|
// src/components/SecurityNumberInvalid/index.tsx
|
|
767
|
-
import { useState as
|
|
871
|
+
import { useState as useState5 } from "react";
|
|
768
872
|
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
769
873
|
function SecurityNumberInvalid({ textColor }) {
|
|
770
|
-
const [openModal, setOpenModal] =
|
|
874
|
+
const [openModal, setOpenModal] = useState5(false);
|
|
875
|
+
const { urlAcceptTerms } = usePBMStore();
|
|
771
876
|
return /* @__PURE__ */ jsxs8(
|
|
772
877
|
"section",
|
|
773
878
|
{
|
|
@@ -789,7 +894,7 @@ function SecurityNumberInvalid({ textColor }) {
|
|
|
789
894
|
/* @__PURE__ */ jsx12(
|
|
790
895
|
Iframe_default,
|
|
791
896
|
{
|
|
792
|
-
url: "
|
|
897
|
+
url: urlAcceptTerms || "",
|
|
793
898
|
title: "Aceitar termos PBM",
|
|
794
899
|
openModal,
|
|
795
900
|
setOpenModal
|
|
@@ -802,7 +907,7 @@ function SecurityNumberInvalid({ textColor }) {
|
|
|
802
907
|
var SecurityNumberInvalid_default = SecurityNumberInvalid;
|
|
803
908
|
|
|
804
909
|
// src/PBM.tsx
|
|
805
|
-
import { useCallback as useCallback2, useEffect as
|
|
910
|
+
import { useCallback as useCallback2, useEffect as useEffect5, useState as useState6 } from "react";
|
|
806
911
|
|
|
807
912
|
// src/components/UI/Link/index.tsx
|
|
808
913
|
import classNames8 from "classnames";
|
|
@@ -823,7 +928,7 @@ function Link(props) {
|
|
|
823
928
|
target: "_blank",
|
|
824
929
|
href: typeof props.href === "string" ? props.href : props.href.pathname + getParams(props.href.param),
|
|
825
930
|
className: classNames8(
|
|
826
|
-
"w-3xs cursor-pointer h-10 rounded-full bg-
|
|
931
|
+
"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",
|
|
827
932
|
props.className
|
|
828
933
|
),
|
|
829
934
|
"data-testid": "test_id_link",
|
|
@@ -837,6 +942,7 @@ var Link_default = Link;
|
|
|
837
942
|
// src/components/SecurityNumberRegitered/index.tsx
|
|
838
943
|
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
839
944
|
function SecurityNumberRegitered({ textColor }) {
|
|
945
|
+
const { urlRegisterIndustry } = usePBMStore();
|
|
840
946
|
return /* @__PURE__ */ jsxs9(
|
|
841
947
|
"section",
|
|
842
948
|
{
|
|
@@ -849,10 +955,7 @@ function SecurityNumberRegitered({ textColor }) {
|
|
|
849
955
|
/* @__PURE__ */ jsx14(
|
|
850
956
|
Link_default,
|
|
851
957
|
{
|
|
852
|
-
href:
|
|
853
|
-
pathname: "https://gip-pd-app.interplayers.com.br/idp-pd-app/adesao",
|
|
854
|
-
param: { guid: "f2aff249-51b4-49a4-b671-d6bee89da0f0" }
|
|
855
|
-
},
|
|
958
|
+
href: urlRegisterIndustry || "",
|
|
856
959
|
children: "Ativar CPF"
|
|
857
960
|
}
|
|
858
961
|
)
|
|
@@ -913,9 +1016,9 @@ function PBM({
|
|
|
913
1016
|
const formatedOriginalProductPrice = Number(
|
|
914
1017
|
String(originalProductPrice).replace(",", ".")
|
|
915
1018
|
);
|
|
916
|
-
const [loading, setLoading] =
|
|
1019
|
+
const [loading, setLoading] = useState6(false);
|
|
917
1020
|
const { setState, state, setTargetProduct } = usePBMStore();
|
|
918
|
-
|
|
1021
|
+
useEffect5(() => {
|
|
919
1022
|
if (eanProduct) {
|
|
920
1023
|
setTargetProduct({ ean: eanProduct });
|
|
921
1024
|
}
|
|
@@ -930,7 +1033,7 @@ function PBM({
|
|
|
930
1033
|
console.error("Error fetching authorization:", error);
|
|
931
1034
|
}
|
|
932
1035
|
}, [clientID]);
|
|
933
|
-
|
|
1036
|
+
useEffect5(() => {
|
|
934
1037
|
handleAuthorizationRequest();
|
|
935
1038
|
}, [handleAuthorizationRequest]);
|
|
936
1039
|
return /* @__PURE__ */ jsxs10(Container_default, { variant: "main", children: [
|