@agrada_digital/pbm 0.0.57 → 0.0.62
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 +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +181 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +181 -84
- 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,84 @@
|
|
|
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
|
+
});
|
|
26
|
+
var pbmStore = createStore(createPBMStore);
|
|
27
|
+
function usePBMStore(selector) {
|
|
28
|
+
if (selector) {
|
|
29
|
+
return useStore(pbmStore, selector);
|
|
30
|
+
}
|
|
31
|
+
return useStore(pbmStore, (state) => state);
|
|
32
|
+
}
|
|
33
|
+
|
|
1
34
|
// src/components/Header/index.tsx
|
|
2
35
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
36
|
function Header({ originalProductPrice }) {
|
|
37
|
+
const { targetProduct } = usePBMStore();
|
|
38
|
+
const Price = targetProduct?.listPrice || originalProductPrice;
|
|
39
|
+
const Discount = Price * ((targetProduct?.discountMax || 0) / 100);
|
|
4
40
|
return /* @__PURE__ */ jsxs(
|
|
5
41
|
"header",
|
|
6
42
|
{
|
|
7
|
-
className: "flex items-center justify-between w-full p-0.5 rounded-full bg-[#44c2c0]/30",
|
|
43
|
+
className: "flex items-center justify-between w-full p-0.5 rounded-full bg-[#44c2c0]/30 mt-5",
|
|
8
44
|
id: "header_pbm",
|
|
9
45
|
children: [
|
|
10
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ jsxs(
|
|
11
47
|
"span",
|
|
12
48
|
{
|
|
13
|
-
className: "py-1 px-6 rounded-full bg-[#44c2c0] shrink-0 text-white text-
|
|
49
|
+
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
50
|
"data-testid": "test_id_header_price",
|
|
15
51
|
id: "header_price",
|
|
16
|
-
children:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
52
|
+
children: [
|
|
53
|
+
/* @__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: [
|
|
54
|
+
Discount.toLocaleString("pt-BR", {
|
|
55
|
+
currency: "BRL",
|
|
56
|
+
currencyDisplay: "symbol",
|
|
57
|
+
currencySign: "standard",
|
|
58
|
+
style: "currency"
|
|
59
|
+
}),
|
|
60
|
+
" OFF"
|
|
61
|
+
] }),
|
|
62
|
+
/* @__PURE__ */ jsxs("svg", { width: "32px", height: "32px", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
63
|
+
/* @__PURE__ */ jsx("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
64
|
+
/* @__PURE__ */ jsx("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
65
|
+
/* @__PURE__ */ jsxs("g", { id: "SVGRepo_iconCarrier", children: [
|
|
66
|
+
/* @__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" }),
|
|
67
|
+
/* @__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" }),
|
|
68
|
+
/* @__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" }),
|
|
69
|
+
/* @__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" })
|
|
70
|
+
] })
|
|
71
|
+
] }),
|
|
72
|
+
Number(Price - Discount)?.toLocaleString("pt-BR", {
|
|
73
|
+
currency: "BRL",
|
|
74
|
+
currencyDisplay: "symbol",
|
|
75
|
+
currencySign: "standard",
|
|
76
|
+
style: "currency"
|
|
77
|
+
})
|
|
78
|
+
]
|
|
22
79
|
}
|
|
23
80
|
),
|
|
24
|
-
/* @__PURE__ */ jsx("h1", { id: "header_title", className: "text-center w-full text-[#339c9b] font-bold text-xs px-4 md:text-sm", children: "
|
|
81
|
+
/* @__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
82
|
]
|
|
26
83
|
}
|
|
27
84
|
);
|
|
@@ -39,7 +96,7 @@ function Container({
|
|
|
39
96
|
"main",
|
|
40
97
|
{
|
|
41
98
|
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",
|
|
99
|
+
"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
100
|
"w-full h-auto relative": variant === "simple"
|
|
44
101
|
}),
|
|
45
102
|
"data-testid": "test_id_container",
|
|
@@ -55,38 +112,6 @@ var Container_default = Container;
|
|
|
55
112
|
import classNames2 from "classnames";
|
|
56
113
|
import { useEffect, useState } from "react";
|
|
57
114
|
|
|
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
115
|
// src/services/get-product-by-ean.ts
|
|
91
116
|
import Cookies from "js-cookie";
|
|
92
117
|
var GetProductByEAN = async ({ PRODUCT_EAN }) => {
|
|
@@ -113,7 +138,7 @@ var GetProductByEAN = async ({ PRODUCT_EAN }) => {
|
|
|
113
138
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
114
139
|
function Footer() {
|
|
115
140
|
const [industryLogo, setIndustryLogo] = useState(null);
|
|
116
|
-
const { targetProduct, setTargetProduct } = usePBMStore();
|
|
141
|
+
const { targetProduct, setTargetProduct, state } = usePBMStore();
|
|
117
142
|
useEffect(() => {
|
|
118
143
|
const fetchProductByEan = async () => {
|
|
119
144
|
if (!targetProduct?.ean) return;
|
|
@@ -124,7 +149,10 @@ function Footer() {
|
|
|
124
149
|
const { pbm, sku, ...targetProductNewData } = response.data;
|
|
125
150
|
setTargetProduct({
|
|
126
151
|
...targetProduct,
|
|
127
|
-
...targetProductNewData
|
|
152
|
+
...targetProductNewData,
|
|
153
|
+
productId: Number(targetProductNewData.productId),
|
|
154
|
+
informativeMessage: pbm.informativeMessage ?? "",
|
|
155
|
+
discountMax: pbm.discountMax ?? 0
|
|
128
156
|
});
|
|
129
157
|
}
|
|
130
158
|
} catch (error) {
|
|
@@ -133,23 +161,26 @@ function Footer() {
|
|
|
133
161
|
};
|
|
134
162
|
fetchProductByEan();
|
|
135
163
|
}, [targetProduct?.ean]);
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */ jsxs2("section", { className: "w-
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
|
|
164
|
+
return /* @__PURE__ */ jsxs2("footer", { className: "w-full h-auto relative", id: "footer_pbm", children: [
|
|
165
|
+
/* @__PURE__ */ jsxs2("section", { className: classNames2("flex items-center w-full h-auto gap-4", { "justify-center": industryLogo, "justify-start": !industryLogo }), children: [
|
|
166
|
+
/* @__PURE__ */ jsxs2("section", { className: "w-4/5 h-auto", children: [
|
|
167
|
+
/* @__PURE__ */ jsx3("h3", { className: "text-start font-semibold text-sm", children: "Economize com o benef\xEDcio do laborat\xF3rio." }),
|
|
168
|
+
/* @__PURE__ */ jsx3("p", { className: "text-start font-normal text-sm", children: "Este produto tem pre\xE7o exclusivo para clientes cadastrados no programa." })
|
|
169
|
+
] }),
|
|
170
|
+
industryLogo && /* @__PURE__ */ jsx3(
|
|
171
|
+
"img",
|
|
172
|
+
{
|
|
173
|
+
src: industryLogo,
|
|
174
|
+
alt: "parceiro",
|
|
175
|
+
className: "w-1/5 min-w-20 h-auto aspect-auto rounded-xl",
|
|
176
|
+
loading: "eager",
|
|
177
|
+
id: "footer_industry_logo_pbm",
|
|
178
|
+
"data-testid": "footer_industry_logo_pbm"
|
|
179
|
+
}
|
|
180
|
+
)
|
|
140
181
|
] }),
|
|
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
|
-
] }) });
|
|
182
|
+
state !== "isActivated" && targetProduct?.informativeMessage && /* @__PURE__ */ jsx3("p", { className: "text-start font-semibold text-sm", children: targetProduct?.informativeMessage })
|
|
183
|
+
] });
|
|
153
184
|
}
|
|
154
185
|
var Footer_default = Footer;
|
|
155
186
|
|
|
@@ -183,9 +214,9 @@ import { useForm } from "react-hook-form";
|
|
|
183
214
|
import { ArrowRight } from "lucide-react";
|
|
184
215
|
import { useState as useState2 } from "react";
|
|
185
216
|
|
|
186
|
-
// src/services/
|
|
217
|
+
// src/services/benefits-with-document.ts
|
|
187
218
|
import Cookies2 from "js-cookie";
|
|
188
|
-
var
|
|
219
|
+
var BenefitsWithDocument = async ({ document: document2, products }) => {
|
|
189
220
|
const API_URL = import.meta.env.VITE_API_URL;
|
|
190
221
|
if (!API_URL) {
|
|
191
222
|
throw new Error("API URL is not defined in environment variables");
|
|
@@ -194,13 +225,13 @@ var ValidateDocument = async ({ document, products }) => {
|
|
|
194
225
|
if (!AUTH_TOKEN) {
|
|
195
226
|
throw new Error("Token is not defined in cookies or is expired");
|
|
196
227
|
}
|
|
197
|
-
const response = await fetch(`${API_URL}/
|
|
228
|
+
const response = await fetch(`${API_URL}/products/benefitByDocument`, {
|
|
198
229
|
method: "POST",
|
|
199
230
|
headers: {
|
|
200
231
|
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
201
232
|
"Content-Type": "application/json"
|
|
202
233
|
},
|
|
203
|
-
body: JSON.stringify({ document, products })
|
|
234
|
+
body: JSON.stringify({ consumer: { document: document2 }, products })
|
|
204
235
|
});
|
|
205
236
|
const dataResponse = await response.json();
|
|
206
237
|
if (!dataResponse.success) {
|
|
@@ -218,7 +249,7 @@ function Button(props) {
|
|
|
218
249
|
{
|
|
219
250
|
...props,
|
|
220
251
|
className: classNames3(
|
|
221
|
-
"w-3xs cursor-pointer h-10 rounded-full bg-
|
|
252
|
+
"w-3xs cursor-pointer h-10 rounded-full bg-emerald-500 hover:bg-emerald-400 text-white text-sm font-semibold transition-colors",
|
|
222
253
|
props.className
|
|
223
254
|
),
|
|
224
255
|
children: props.children
|
|
@@ -230,7 +261,7 @@ var Button_default = Button;
|
|
|
230
261
|
// src/components/Form/index.tsx
|
|
231
262
|
import { Fragment, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
232
263
|
function Form({ setLoading }) {
|
|
233
|
-
const { setSecurityNumber, setState, securityNumber, targetProduct } = usePBMStore();
|
|
264
|
+
const { setSecurityNumber, setState, securityNumber, targetProduct, setUrlAcceptTerms } = usePBMStore();
|
|
234
265
|
const [showCoupoField, setShowCoupoField] = useState2(false);
|
|
235
266
|
const {
|
|
236
267
|
handleSubmit,
|
|
@@ -257,17 +288,33 @@ function Form({ setLoading }) {
|
|
|
257
288
|
console.error("PBMLOG: Product is not defined!");
|
|
258
289
|
return;
|
|
259
290
|
}
|
|
260
|
-
|
|
291
|
+
if (!targetProduct.productId) {
|
|
292
|
+
console.error("PBMLOG: Product ID is not defined!");
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (!targetProduct.listPrice) {
|
|
296
|
+
console.error("PBMLOG: List Price is not defined!");
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const response = await BenefitsWithDocument({
|
|
261
300
|
document: values.securityNumber.replace(/\D/g, ""),
|
|
262
|
-
products: [{
|
|
301
|
+
products: [{
|
|
302
|
+
productId: targetProduct.productId,
|
|
303
|
+
ean: targetProduct.ean,
|
|
304
|
+
requestedQuantity: 1,
|
|
305
|
+
listPrice: targetProduct.listPrice,
|
|
306
|
+
netPrice: targetProduct.netPrice ?? targetProduct.listPrice
|
|
307
|
+
}]
|
|
263
308
|
});
|
|
264
309
|
if (response.success) {
|
|
265
310
|
const status = {
|
|
266
|
-
"
|
|
267
|
-
"
|
|
311
|
+
"acceptance": "isInvalid",
|
|
312
|
+
"industry registration": "isRegistered",
|
|
313
|
+
"active": "isActivated"
|
|
268
314
|
};
|
|
269
315
|
setSecurityNumber(values.securityNumber);
|
|
270
|
-
setState(status[response.data.
|
|
316
|
+
setState(status[response.data.product[0].statusCustumer]);
|
|
317
|
+
setUrlAcceptTerms(response.data.product[0].urlAcceptTerm || void 0);
|
|
271
318
|
}
|
|
272
319
|
} catch (error) {
|
|
273
320
|
console.error("PBMLOG: Error validating document -", error);
|
|
@@ -299,7 +346,7 @@ function Form({ setLoading }) {
|
|
|
299
346
|
{
|
|
300
347
|
type: "text",
|
|
301
348
|
className: classNames4(
|
|
302
|
-
"w-full h-8 bg-
|
|
349
|
+
"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
350
|
{ "outline outline-red-600": errors.securityNumber, "rounded-full": showCoupoField }
|
|
304
351
|
),
|
|
305
352
|
placeholder: "Digite seu CPF aqui...",
|
|
@@ -358,7 +405,7 @@ function Form({ setLoading }) {
|
|
|
358
405
|
{
|
|
359
406
|
type: "submit",
|
|
360
407
|
className: classNames4(
|
|
361
|
-
"bg-
|
|
408
|
+
"bg-emerald-500 w-1/5 h-8 flex items-center justify-center rounded-e-full cursor-pointer",
|
|
362
409
|
{ "rounded-full": showCoupoField }
|
|
363
410
|
),
|
|
364
411
|
id: "button_submit_security_number_pbm",
|
|
@@ -698,9 +745,39 @@ var Text_default = Text;
|
|
|
698
745
|
|
|
699
746
|
// src/components/Iframe/index.tsx
|
|
700
747
|
import classNames7 from "classnames";
|
|
701
|
-
import { TriangleAlert } from "lucide-react";
|
|
748
|
+
import { TriangleAlert, ExternalLink } from "lucide-react";
|
|
749
|
+
import { useState as useState4, useEffect as useEffect4 } from "react";
|
|
702
750
|
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
703
751
|
function Iframe({ url, title, openModal, setOpenModal }) {
|
|
752
|
+
const [_, setIframeError] = useState4(false);
|
|
753
|
+
const [showFallback, setShowFallback] = useState4(false);
|
|
754
|
+
useEffect4(() => {
|
|
755
|
+
if (openModal && url) {
|
|
756
|
+
setIframeError(false);
|
|
757
|
+
setShowFallback(false);
|
|
758
|
+
const timeout = setTimeout(() => {
|
|
759
|
+
const iframe = document.querySelector('iframe[src="' + url + '"]');
|
|
760
|
+
if (iframe) {
|
|
761
|
+
try {
|
|
762
|
+
const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
763
|
+
if (!iframeDoc) {
|
|
764
|
+
setIframeError(true);
|
|
765
|
+
setShowFallback(true);
|
|
766
|
+
}
|
|
767
|
+
} catch (e) {
|
|
768
|
+
setIframeError(true);
|
|
769
|
+
setShowFallback(true);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}, 2e3);
|
|
773
|
+
return () => clearTimeout(timeout);
|
|
774
|
+
}
|
|
775
|
+
}, [openModal, url]);
|
|
776
|
+
const handleOpenInNewWindow = () => {
|
|
777
|
+
if (url) {
|
|
778
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
779
|
+
}
|
|
780
|
+
};
|
|
704
781
|
return /* @__PURE__ */ jsxs7(
|
|
705
782
|
"main",
|
|
706
783
|
{
|
|
@@ -737,7 +814,22 @@ function Iframe({ url, title, openModal, setOpenModal }) {
|
|
|
737
814
|
children: "Fechar"
|
|
738
815
|
}
|
|
739
816
|
) }),
|
|
740
|
-
/* @__PURE__ */
|
|
817
|
+
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: [
|
|
818
|
+
/* @__PURE__ */ jsx11(TriangleAlert, { size: 48, className: "text-yellow-500 mb-4" }),
|
|
819
|
+
/* @__PURE__ */ jsx11("h3", { className: "text-white text-xl font-bold mb-4 text-center", children: "N\xE3o foi poss\xEDvel carregar o conte\xFAdo" }),
|
|
820
|
+
/* @__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." }),
|
|
821
|
+
/* @__PURE__ */ jsxs7(
|
|
822
|
+
"button",
|
|
823
|
+
{
|
|
824
|
+
onClick: handleOpenInNewWindow,
|
|
825
|
+
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",
|
|
826
|
+
children: [
|
|
827
|
+
/* @__PURE__ */ jsx11(ExternalLink, { size: 20 }),
|
|
828
|
+
"Abrir em nova janela"
|
|
829
|
+
]
|
|
830
|
+
}
|
|
831
|
+
)
|
|
832
|
+
] }) : /* @__PURE__ */ jsx11(
|
|
741
833
|
"iframe",
|
|
742
834
|
{
|
|
743
835
|
src: url,
|
|
@@ -745,7 +837,11 @@ function Iframe({ url, title, openModal, setOpenModal }) {
|
|
|
745
837
|
width: "80%",
|
|
746
838
|
height: "80%",
|
|
747
839
|
allowFullScreen: true,
|
|
748
|
-
className: "z-10"
|
|
840
|
+
className: "z-10",
|
|
841
|
+
onError: () => {
|
|
842
|
+
setIframeError(true);
|
|
843
|
+
setShowFallback(true);
|
|
844
|
+
}
|
|
749
845
|
}
|
|
750
846
|
),
|
|
751
847
|
/* @__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 +860,11 @@ function Iframe({ url, title, openModal, setOpenModal }) {
|
|
|
764
860
|
var Iframe_default = Iframe;
|
|
765
861
|
|
|
766
862
|
// src/components/SecurityNumberInvalid/index.tsx
|
|
767
|
-
import { useState as
|
|
863
|
+
import { useState as useState5 } from "react";
|
|
768
864
|
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
769
865
|
function SecurityNumberInvalid({ textColor }) {
|
|
770
|
-
const [openModal, setOpenModal] =
|
|
866
|
+
const [openModal, setOpenModal] = useState5(false);
|
|
867
|
+
const { urlAcceptTerms } = usePBMStore();
|
|
771
868
|
return /* @__PURE__ */ jsxs8(
|
|
772
869
|
"section",
|
|
773
870
|
{
|
|
@@ -789,7 +886,7 @@ function SecurityNumberInvalid({ textColor }) {
|
|
|
789
886
|
/* @__PURE__ */ jsx12(
|
|
790
887
|
Iframe_default,
|
|
791
888
|
{
|
|
792
|
-
url: "
|
|
889
|
+
url: urlAcceptTerms || "",
|
|
793
890
|
title: "Aceitar termos PBM",
|
|
794
891
|
openModal,
|
|
795
892
|
setOpenModal
|
|
@@ -802,7 +899,7 @@ function SecurityNumberInvalid({ textColor }) {
|
|
|
802
899
|
var SecurityNumberInvalid_default = SecurityNumberInvalid;
|
|
803
900
|
|
|
804
901
|
// src/PBM.tsx
|
|
805
|
-
import { useCallback as useCallback2, useEffect as
|
|
902
|
+
import { useCallback as useCallback2, useEffect as useEffect5, useState as useState6 } from "react";
|
|
806
903
|
|
|
807
904
|
// src/components/UI/Link/index.tsx
|
|
808
905
|
import classNames8 from "classnames";
|
|
@@ -913,9 +1010,9 @@ function PBM({
|
|
|
913
1010
|
const formatedOriginalProductPrice = Number(
|
|
914
1011
|
String(originalProductPrice).replace(",", ".")
|
|
915
1012
|
);
|
|
916
|
-
const [loading, setLoading] =
|
|
1013
|
+
const [loading, setLoading] = useState6(false);
|
|
917
1014
|
const { setState, state, setTargetProduct } = usePBMStore();
|
|
918
|
-
|
|
1015
|
+
useEffect5(() => {
|
|
919
1016
|
if (eanProduct) {
|
|
920
1017
|
setTargetProduct({ ean: eanProduct });
|
|
921
1018
|
}
|
|
@@ -930,7 +1027,7 @@ function PBM({
|
|
|
930
1027
|
console.error("Error fetching authorization:", error);
|
|
931
1028
|
}
|
|
932
1029
|
}, [clientID]);
|
|
933
|
-
|
|
1030
|
+
useEffect5(() => {
|
|
934
1031
|
handleAuthorizationRequest();
|
|
935
1032
|
}, [handleAuthorizationRequest]);
|
|
936
1033
|
return /* @__PURE__ */ jsxs10(Container_default, { variant: "main", children: [
|