@agrada_digital/pbm 0.0.85 → 0.0.87
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +238 -152
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +248 -162
- package/dist/index.mjs.map +1 -1
- package/dist-wc/pbm-wc.js +115 -115
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,7 @@ interface usePBMTypes {
|
|
|
28
28
|
urlAcceptTerms?: string;
|
|
29
29
|
urlRegisterIndustry?: string;
|
|
30
30
|
customLoginUrl?: string;
|
|
31
|
+
cardID?: string | number;
|
|
31
32
|
}
|
|
32
33
|
interface IProduct {
|
|
33
34
|
ean: string;
|
|
@@ -57,6 +58,7 @@ interface PBMStore extends usePBMTypes {
|
|
|
57
58
|
setUrlRegisterIndustry: (urlRegisterIndustry: usePBMTypes["urlRegisterIndustry"]) => void;
|
|
58
59
|
setIsAuthenticatedShopper: (isAuthenticatedShopper: usePBMTypes["isAuthenticatedShopper"]) => void;
|
|
59
60
|
setCustomLoginUrl: (customLoginUrl: usePBMTypes["customLoginUrl"]) => void;
|
|
61
|
+
setCardID: (cardID: usePBMTypes["cardID"]) => void;
|
|
60
62
|
}
|
|
61
63
|
declare function usePBMStore(): PBMStore;
|
|
62
64
|
declare function usePBMStore<T>(selector: (state: PBMStore) => T): T;
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ interface usePBMTypes {
|
|
|
28
28
|
urlAcceptTerms?: string;
|
|
29
29
|
urlRegisterIndustry?: string;
|
|
30
30
|
customLoginUrl?: string;
|
|
31
|
+
cardID?: string | number;
|
|
31
32
|
}
|
|
32
33
|
interface IProduct {
|
|
33
34
|
ean: string;
|
|
@@ -57,6 +58,7 @@ interface PBMStore extends usePBMTypes {
|
|
|
57
58
|
setUrlRegisterIndustry: (urlRegisterIndustry: usePBMTypes["urlRegisterIndustry"]) => void;
|
|
58
59
|
setIsAuthenticatedShopper: (isAuthenticatedShopper: usePBMTypes["isAuthenticatedShopper"]) => void;
|
|
59
60
|
setCustomLoginUrl: (customLoginUrl: usePBMTypes["customLoginUrl"]) => void;
|
|
61
|
+
setCardID: (cardID: usePBMTypes["cardID"]) => void;
|
|
60
62
|
}
|
|
61
63
|
declare function usePBMStore(): PBMStore;
|
|
62
64
|
declare function usePBMStore<T>(selector: (state: PBMStore) => T): T;
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ var import_zustand = require("zustand");
|
|
|
40
40
|
var import_react = require("zustand/react");
|
|
41
41
|
var initialPBMState = {
|
|
42
42
|
securityNumber: "",
|
|
43
|
+
cardID: "",
|
|
43
44
|
state: "isEmpty",
|
|
44
45
|
availableDiscountSelected: {
|
|
45
46
|
quantity: 0,
|
|
@@ -64,7 +65,8 @@ var createPBMStore = (set) => ({
|
|
|
64
65
|
setUrlAcceptTerms: (urlAcceptTerms) => set({ urlAcceptTerms }),
|
|
65
66
|
setUrlRegisterIndustry: (urlRegisterIndustry) => set({ urlRegisterIndustry }),
|
|
66
67
|
setIsAuthenticatedShopper: (isAuthenticatedShopper) => set({ isAuthenticatedShopper }),
|
|
67
|
-
setCustomLoginUrl: (customLoginUrl) => set({ customLoginUrl })
|
|
68
|
+
setCustomLoginUrl: (customLoginUrl) => set({ customLoginUrl }),
|
|
69
|
+
setCardID: (cardID) => set({ cardID })
|
|
68
70
|
});
|
|
69
71
|
var pbmStore = (0, import_zustand.createStore)(createPBMStore);
|
|
70
72
|
function usePBMStore(selector) {
|
|
@@ -190,7 +192,7 @@ var toFormat = (value) => {
|
|
|
190
192
|
};
|
|
191
193
|
|
|
192
194
|
// src/components/Form/index.tsx
|
|
193
|
-
var
|
|
195
|
+
var import_classnames4 = __toESM(require("classnames"));
|
|
194
196
|
var import_zod2 = require("@hookform/resolvers/zod");
|
|
195
197
|
var import_react_hook_form = require("react-hook-form");
|
|
196
198
|
var import_lucide_react = require("lucide-react");
|
|
@@ -223,11 +225,29 @@ var BenefitsWithDocument = async ({ document, products }) => {
|
|
|
223
225
|
return dataResponse;
|
|
224
226
|
};
|
|
225
227
|
|
|
226
|
-
// src/components/
|
|
228
|
+
// src/components/UI/Button/index.tsx
|
|
229
|
+
var import_classnames3 = __toESM(require("classnames"));
|
|
227
230
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
231
|
+
function Button(props) {
|
|
232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
233
|
+
"button",
|
|
234
|
+
{
|
|
235
|
+
...props,
|
|
236
|
+
className: (0, import_classnames3.default)(
|
|
237
|
+
"w-3xs cursor-pointer h-10 rounded-lg bg-emerald-500 hover:bg-emerald-400 text-white text-sm font-semibold transition-colors",
|
|
238
|
+
props.className
|
|
239
|
+
),
|
|
240
|
+
children: props.children
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
var Button_default = Button;
|
|
245
|
+
|
|
246
|
+
// src/components/Form/index.tsx
|
|
247
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
228
248
|
function Form({ setLoading }) {
|
|
229
|
-
const { setSecurityNumber, setState, securityNumber, targetProduct, setUrlAcceptTerms, setUrlRegisterIndustry } = usePBMStore();
|
|
230
|
-
const [
|
|
249
|
+
const { setSecurityNumber, setState, securityNumber, targetProduct, setUrlAcceptTerms, setUrlRegisterIndustry, setCardID } = usePBMStore();
|
|
250
|
+
const [showCardIDField, setShowCardIDField] = (0, import_react2.useState)(false);
|
|
231
251
|
const {
|
|
232
252
|
handleSubmit,
|
|
233
253
|
register,
|
|
@@ -244,9 +264,12 @@ function Form({ setLoading }) {
|
|
|
244
264
|
}
|
|
245
265
|
});
|
|
246
266
|
const onSubmitDefault = async (values) => {
|
|
247
|
-
if (!
|
|
267
|
+
if (!showCardIDField) {
|
|
248
268
|
setValue("coupon", void 0, { shouldValidate: false });
|
|
249
269
|
}
|
|
270
|
+
if (showCardIDField && values.coupon != void 0) {
|
|
271
|
+
setCardID(values.coupon);
|
|
272
|
+
}
|
|
250
273
|
setLoading(true);
|
|
251
274
|
try {
|
|
252
275
|
if (targetProduct === null) {
|
|
@@ -295,105 +318,140 @@ function Form({ setLoading }) {
|
|
|
295
318
|
}
|
|
296
319
|
;
|
|
297
320
|
};
|
|
298
|
-
return /* @__PURE__ */ (0,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
id: "form_security_number_pbm",
|
|
307
|
-
children: [
|
|
308
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
309
|
-
"label",
|
|
310
|
-
{
|
|
311
|
-
htmlFor: "cpf",
|
|
312
|
-
className: "w-4/5 h-auto flex items-start flex-col justify-center relative py-2",
|
|
313
|
-
id: "label_security_number_pbm",
|
|
314
|
-
children: [
|
|
315
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
316
|
-
"input",
|
|
317
|
-
{
|
|
318
|
-
type: "text",
|
|
319
|
-
className: (0, import_classnames3.default)(
|
|
320
|
-
"w-full h-10 bg-gray-100 rounded-s-lg 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",
|
|
321
|
-
{ "outline outline-red-600": errors.securityNumber, "rounded-lg": showCoupoField }
|
|
322
|
-
),
|
|
323
|
-
placeholder: "Digite seu CPF aqui...",
|
|
324
|
-
required: true,
|
|
325
|
-
maxLength: 14,
|
|
326
|
-
...register("securityNumber", {
|
|
327
|
-
onChange: (e) => {
|
|
328
|
-
const formatted = toFormat(e.target.value);
|
|
329
|
-
setValue("securityNumber", formatted, {
|
|
330
|
-
shouldValidate: true
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
}),
|
|
334
|
-
defaultValue: securityNumber || "",
|
|
335
|
-
id: "input_security_number_pbm"
|
|
336
|
-
}
|
|
337
|
-
),
|
|
338
|
-
errors.securityNumber && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-red-400 text-xs font-semibold absolute -bottom-3 left-2 text-nowrap", id: "security_number_form_error", children: errors.securityNumber.message })
|
|
339
|
-
]
|
|
340
|
-
}
|
|
321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
322
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
323
|
+
"form",
|
|
324
|
+
{
|
|
325
|
+
onSubmit: handleSubmit(onSubmitDefault),
|
|
326
|
+
className: (0, import_classnames4.default)(
|
|
327
|
+
"w-full h-auto flex items-center justify-center mb-0 transition-all duration-150",
|
|
328
|
+
{ "mb-4": errors.securityNumber || errors.coupon && showCardIDField, "gap-2": showCardIDField }
|
|
341
329
|
),
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
330
|
+
id: "form_security_number_pbm",
|
|
331
|
+
children: [
|
|
332
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
333
|
+
"label",
|
|
334
|
+
{
|
|
335
|
+
htmlFor: "cpf",
|
|
336
|
+
className: "w-4/5 h-auto flex items-start flex-col justify-center relative py-2",
|
|
337
|
+
id: "label_security_number_pbm",
|
|
338
|
+
children: [
|
|
339
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
340
|
+
"input",
|
|
341
|
+
{
|
|
342
|
+
type: "text",
|
|
343
|
+
className: (0, import_classnames4.default)(
|
|
344
|
+
"w-full h-10 bg-gray-100 rounded-s-lg 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",
|
|
345
|
+
{ "outline outline-red-600": errors.securityNumber, "rounded-lg": showCardIDField }
|
|
346
|
+
),
|
|
347
|
+
placeholder: "Digite seu CPF aqui...",
|
|
348
|
+
required: true,
|
|
349
|
+
maxLength: 14,
|
|
350
|
+
...register("securityNumber", {
|
|
351
|
+
onChange: (e) => {
|
|
352
|
+
const formatted = toFormat(e.target.value);
|
|
353
|
+
setValue("securityNumber", formatted, {
|
|
354
|
+
shouldValidate: true
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}),
|
|
358
|
+
defaultValue: securityNumber || "",
|
|
359
|
+
id: "input_security_number_pbm"
|
|
360
|
+
}
|
|
361
|
+
),
|
|
362
|
+
errors.securityNumber && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-red-400 text-xs font-semibold absolute -bottom-3 left-2 text-nowrap", id: "security_number_form_error", children: errors.securityNumber.message })
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
),
|
|
366
|
+
showCardIDField && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
367
|
+
"label",
|
|
368
|
+
{
|
|
369
|
+
htmlFor: "coupon",
|
|
370
|
+
className: "w-4/5 h-auto flex items-start flex-col justify-center relative py-2",
|
|
371
|
+
id: "label_coupon_pbm",
|
|
372
|
+
children: [
|
|
373
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
374
|
+
"input",
|
|
375
|
+
{
|
|
376
|
+
type: "text",
|
|
377
|
+
className: (0, import_classnames4.default)(
|
|
378
|
+
"w-full h-10 bg-gray-100 rounded-s-lg 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",
|
|
379
|
+
{ "outline outline-red-600": errors.coupon, "rounded-lg": showCardIDField }
|
|
380
|
+
),
|
|
381
|
+
placeholder: "Cupom / ID do Cart\xE3o",
|
|
382
|
+
...register("coupon", {
|
|
383
|
+
required: showCardIDField ? "Cupom / ID do Cart\xE3o obrigat\xF3rio." : false,
|
|
384
|
+
shouldUnregister: !showCardIDField,
|
|
385
|
+
onChange: (e) => {
|
|
386
|
+
setValue("coupon", e.target.value, {
|
|
387
|
+
shouldValidate: showCardIDField
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
}),
|
|
391
|
+
id: "input_coupon_pbm"
|
|
392
|
+
}
|
|
393
|
+
),
|
|
394
|
+
errors.coupon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-red-400 text-xs font-semibold absolute -bottom-3 left-2 text-nowrap", id: "coupon_form_error", children: errors.coupon.message })
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
),
|
|
398
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
399
|
+
"button",
|
|
400
|
+
{
|
|
401
|
+
type: "submit",
|
|
402
|
+
className: (0, import_classnames4.default)(
|
|
403
|
+
"bg-emerald-500 w-1/5 h-10 rounded-e-lg flex items-center justify-center cursor-pointer",
|
|
404
|
+
{ "rounded-lg": showCardIDField }
|
|
369
405
|
),
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
406
|
+
id: "button_submit_security_number_pbm",
|
|
407
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.ArrowRight, { size: 24, color: "white", strokeWidth: 2 })
|
|
408
|
+
}
|
|
409
|
+
)
|
|
410
|
+
]
|
|
411
|
+
}
|
|
412
|
+
),
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: "flex items-center-safe justify-between", children: [
|
|
414
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
415
|
+
Button_default,
|
|
416
|
+
{
|
|
417
|
+
className: "bg-transparent p-0 pl-2 w-auto h-auto text-zinc-600 underline cursor-pointer hover:text-zinc-900 hover:bg-transparent flex items-center justify-start gap-1",
|
|
418
|
+
onClick: () => {
|
|
419
|
+
const newValue = !showCardIDField;
|
|
420
|
+
setShowCardIDField(newValue);
|
|
421
|
+
if (!newValue) {
|
|
422
|
+
unregister("coupon");
|
|
423
|
+
clearErrors("coupon");
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
id: "check_benefits_button",
|
|
427
|
+
children: [
|
|
428
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: !showCardIDField ? "Possui Cupom / ID do Cart\xE3o?" : "N\xE3o possui Cupom / ID do Cart\xE3o??" }),
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.ArrowRight, { size: 16, className: (0, import_classnames4.default)({ "rotate-0": !showCardIDField, "rotate-180": showCardIDField }) })
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
),
|
|
433
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
434
|
+
Button_default,
|
|
435
|
+
{
|
|
436
|
+
className: "bg-transparent p-0 pl-2 w-auto h-auto text-zinc-600 underline cursor-pointer hover:text-zinc-900 hover:bg-transparent flex items-center justify-start gap-1",
|
|
437
|
+
onClick: () => setState("isPreview"),
|
|
438
|
+
id: "check_benefits_button",
|
|
439
|
+
children: [
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Consultar Benef\xEDcios" }),
|
|
441
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.ArrowRight, { size: 16 })
|
|
442
|
+
]
|
|
443
|
+
}
|
|
444
|
+
)
|
|
445
|
+
] })
|
|
446
|
+
] });
|
|
389
447
|
}
|
|
390
448
|
var Form_default = Form;
|
|
391
449
|
|
|
392
450
|
// src/components/UI/Loading/index.tsx
|
|
393
|
-
var
|
|
451
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
394
452
|
function Loading({ textColor }) {
|
|
395
|
-
return /* @__PURE__ */ (0,
|
|
396
|
-
/* @__PURE__ */ (0,
|
|
453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("main", { className: "flex items-center justify-center gap-4", id: "loading_pbm", children: [
|
|
454
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
397
455
|
"div",
|
|
398
456
|
{
|
|
399
457
|
"data-testid": "test_id_spin",
|
|
@@ -401,7 +459,7 @@ function Loading({ textColor }) {
|
|
|
401
459
|
id: "loading_spin"
|
|
402
460
|
}
|
|
403
461
|
),
|
|
404
|
-
/* @__PURE__ */ (0,
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
405
463
|
"p",
|
|
406
464
|
{
|
|
407
465
|
className: "text-sm font-semibold text-start text-zinc-900",
|
|
@@ -414,24 +472,6 @@ function Loading({ textColor }) {
|
|
|
414
472
|
}
|
|
415
473
|
var Loading_default = Loading;
|
|
416
474
|
|
|
417
|
-
// src/components/UI/Button/index.tsx
|
|
418
|
-
var import_classnames4 = __toESM(require("classnames"));
|
|
419
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
420
|
-
function Button(props) {
|
|
421
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
422
|
-
"button",
|
|
423
|
-
{
|
|
424
|
-
...props,
|
|
425
|
-
className: (0, import_classnames4.default)(
|
|
426
|
-
"w-3xs cursor-pointer h-10 rounded-lg bg-emerald-500 hover:bg-emerald-400 text-white text-sm font-semibold transition-colors",
|
|
427
|
-
props.className
|
|
428
|
-
),
|
|
429
|
-
children: props.children
|
|
430
|
-
}
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
var Button_default = Button;
|
|
434
|
-
|
|
435
475
|
// src/components/BenefitsTable/index.tsx
|
|
436
476
|
var import_react4 = require("react");
|
|
437
477
|
|
|
@@ -446,7 +486,7 @@ function Title(props) {
|
|
|
446
486
|
"text-start font-semibold text-sm text-zinc-900",
|
|
447
487
|
props.className
|
|
448
488
|
),
|
|
449
|
-
style: { color: props.textColor, fontSize: props.textSize },
|
|
489
|
+
style: { color: props.textColor, fontSize: props.textSize, textAlign: props.textAlign },
|
|
450
490
|
"data-testid": "test_id_title",
|
|
451
491
|
id: "title_pbm",
|
|
452
492
|
children: props.children
|
|
@@ -455,6 +495,20 @@ function Title(props) {
|
|
|
455
495
|
}
|
|
456
496
|
var Title_default = Title;
|
|
457
497
|
|
|
498
|
+
// src/libs/zustand/useModal.tsx
|
|
499
|
+
var import_zustand2 = require("zustand");
|
|
500
|
+
var initialModalState = {
|
|
501
|
+
modal: {
|
|
502
|
+
id: "",
|
|
503
|
+
open: false
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
var createModalStore = (set) => ({
|
|
507
|
+
...initialModalState,
|
|
508
|
+
setModal: (modal) => set({ modal })
|
|
509
|
+
});
|
|
510
|
+
var useModal = (0, import_zustand2.create)(createModalStore);
|
|
511
|
+
|
|
458
512
|
// src/components/BenefitsTable/Item.tsx
|
|
459
513
|
var import_react3 = require("react");
|
|
460
514
|
var import_classnames6 = __toESM(require("classnames"));
|
|
@@ -511,6 +565,8 @@ var Icons = {
|
|
|
511
565
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
512
566
|
function Item({ data, onChange, checked }) {
|
|
513
567
|
const { setAvailableDiscountSelected, state, isAuthenticatedShopper } = usePBMStore();
|
|
568
|
+
const { setModal } = useModal();
|
|
569
|
+
const [openModalAlert, setOpenModalAlert] = (0, import_react3.useState)(false);
|
|
514
570
|
const ID_INPUT = "unity_quantity_" + data.authorizedQuantity;
|
|
515
571
|
const decimalDiscount = data.discountPercentual / 100;
|
|
516
572
|
const unitDiscountValue = data.grossPrice * decimalDiscount;
|
|
@@ -540,16 +596,23 @@ function Item({ data, onChange, checked }) {
|
|
|
540
596
|
(0, import_react3.useEffect)(() => {
|
|
541
597
|
updateStorageData();
|
|
542
598
|
}, [updateStorageData]);
|
|
599
|
+
const CheckUserIsAuthenticated = () => {
|
|
600
|
+
if (isAuthenticatedShopper) return;
|
|
601
|
+
setModal({
|
|
602
|
+
id: "ShopperIsNotAuthenticated",
|
|
603
|
+
open: true
|
|
604
|
+
});
|
|
605
|
+
};
|
|
543
606
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
544
607
|
"label",
|
|
545
608
|
{
|
|
546
609
|
htmlFor: ID_INPUT,
|
|
547
610
|
className: (0, import_classnames6.default)(
|
|
548
611
|
"label_benefits w-full flex items-center justify-start bg-zinc-300/60 border border-zinc-400/50 px-4 py-2 hover:bg-zinc-300 transition-colors rounded-lg gap-1",
|
|
549
|
-
{ "cursor-not-allowed": state === "isPreview"
|
|
612
|
+
{ "cursor-not-allowed": state === "isPreview", "cursor-pointer": state === "isActivated" }
|
|
550
613
|
),
|
|
551
614
|
id: "label_benefits_" + ID_INPUT,
|
|
552
|
-
|
|
615
|
+
onClick: CheckUserIsAuthenticated,
|
|
553
616
|
children: [
|
|
554
617
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
555
618
|
"input",
|
|
@@ -560,7 +623,7 @@ function Item({ data, onChange, checked }) {
|
|
|
560
623
|
className: "hidden",
|
|
561
624
|
checked,
|
|
562
625
|
onChange,
|
|
563
|
-
disabled: state === "isPreview"
|
|
626
|
+
disabled: state === "isPreview"
|
|
564
627
|
}
|
|
565
628
|
),
|
|
566
629
|
!checked ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icons.CheckOFF, { size: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icons.CheckON, { size: 20 }),
|
|
@@ -968,7 +1031,41 @@ var GetProductByEAN = async ({ PRODUCT_EAN }) => {
|
|
|
968
1031
|
|
|
969
1032
|
// src/PBM.tsx
|
|
970
1033
|
var import_Skeleton = __toESM(require("@mui/material/Skeleton"));
|
|
1034
|
+
|
|
1035
|
+
// src/components/Modal/index.tsx
|
|
1036
|
+
var import_classnames9 = __toESM(require("classnames"));
|
|
971
1037
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1038
|
+
var Modal = ({ ID }) => {
|
|
1039
|
+
const { customLoginUrl } = usePBMStore();
|
|
1040
|
+
const { modal, setModal } = useModal();
|
|
1041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("main", { className: (0, import_classnames9.default)(
|
|
1042
|
+
"fixed inset-0 flex items-center justify-center z-50 flex-col transition-all shadow bg-black/40",
|
|
1043
|
+
{
|
|
1044
|
+
"opacity-100 pointer-events-auto": modal.id === ID && modal.open,
|
|
1045
|
+
"opacity-0 pointer-events-none": modal.id != ID || !modal.open
|
|
1046
|
+
}
|
|
1047
|
+
), children: [
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "absolute inset-0", onClick: () => setModal({ id: "", open: false }) }),
|
|
1049
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("section", { className: "z-10 bg-white gap-2 flex-col items-center-safe justify-center-safe p-8 rounded-xl", children: [
|
|
1050
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Title_default, { textColor: "tomato", textSize: "18px", textAlign: "center", className: "mb-2", children: "Opa! Parece que voc\xEA n\xE3o est\xE1 Logado" }),
|
|
1051
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Text_default, { className: "mb-2", textAlign: "center", children: [
|
|
1052
|
+
"Para aproveitar os benef\xEDcios \xE9 necess\xE1rio realizar o ",
|
|
1053
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("strong", { children: "Login" }),
|
|
1054
|
+
" ou ",
|
|
1055
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("strong", { children: "Cadastro" }),
|
|
1056
|
+
" no site!"
|
|
1057
|
+
] }),
|
|
1058
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("section", { className: "flex items-center-safe justify-center-safe gap-4", children: [
|
|
1059
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Button_default, { className: "bg-gray-600 hover:bg-gray-500", onClick: () => setModal({ id: "", open: false }), children: "Seguir sem Benef\xEDcios" }),
|
|
1060
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Link_default, { href: customLoginUrl || "/login", children: "Aproveitar Benef\xEDcios" })
|
|
1061
|
+
] })
|
|
1062
|
+
] })
|
|
1063
|
+
] });
|
|
1064
|
+
};
|
|
1065
|
+
var Modal_default = Modal;
|
|
1066
|
+
|
|
1067
|
+
// src/PBM.tsx
|
|
1068
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
972
1069
|
function PBM({
|
|
973
1070
|
originalProductPrice,
|
|
974
1071
|
clientID,
|
|
@@ -1028,55 +1125,44 @@ function PBM({
|
|
|
1028
1125
|
handleAuthorizationRequest();
|
|
1029
1126
|
}, [handleAuthorizationRequest]);
|
|
1030
1127
|
if (!isReady) {
|
|
1031
|
-
return /* @__PURE__ */ (0,
|
|
1128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_Skeleton.default, { variant: "rectangular", style: { borderRadius: "12px" }, width: 460, height: 358 });
|
|
1032
1129
|
}
|
|
1033
1130
|
if (!EanProductExist) {
|
|
1034
|
-
return /* @__PURE__ */ (0,
|
|
1035
|
-
/* @__PURE__ */ (0,
|
|
1036
|
-
/* @__PURE__ */ (0,
|
|
1131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id: "pbm-library-root", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Container_default, { variant: "main", children: [
|
|
1132
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Title_default, { children: "Erro ao Aplicar o Benef\xEDcio" }),
|
|
1133
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Text_default, { textAlign: "center", children: [
|
|
1037
1134
|
"O produto n\xE3o foi encontrado no sistema. ",
|
|
1038
|
-
/* @__PURE__ */ (0,
|
|
1135
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("br", {}),
|
|
1039
1136
|
" Por favor, tente novamente mais tarde ou contate o suporte."
|
|
1040
1137
|
] }),
|
|
1041
|
-
/* @__PURE__ */ (0,
|
|
1138
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1042
1139
|
Button_default,
|
|
1043
1140
|
{
|
|
1044
1141
|
className: "bg-transparent p-0 pl-2 w-auto h-auto text-zinc-600 underline cursor-pointer hover:text-zinc-900 hover:bg-transparent flex items-center justify-start gap-1",
|
|
1045
1142
|
onClick: () => window.location.reload(),
|
|
1046
1143
|
id: "check_benefits_button",
|
|
1047
1144
|
children: [
|
|
1048
|
-
/* @__PURE__ */ (0,
|
|
1049
|
-
/* @__PURE__ */ (0,
|
|
1145
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: "Tentar novamente" }),
|
|
1146
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react2.RefreshCw, { size: 16 })
|
|
1050
1147
|
]
|
|
1051
1148
|
}
|
|
1052
1149
|
)
|
|
1053
1150
|
] }) });
|
|
1054
1151
|
}
|
|
1055
|
-
return /* @__PURE__ */ (0,
|
|
1056
|
-
/* @__PURE__ */ (0,
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
/* @__PURE__ */ (0,
|
|
1060
|
-
/* @__PURE__ */ (0,
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
onClick: () => setState("isPreview"),
|
|
1065
|
-
id: "check_benefits_button",
|
|
1066
|
-
children: [
|
|
1067
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: "Consultar benef\xEDcios" }),
|
|
1068
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react2.ArrowRight, { size: 16 })
|
|
1069
|
-
]
|
|
1070
|
-
}
|
|
1071
|
-
)
|
|
1152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { id: "pbm-library-root", children: [
|
|
1153
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Container_default, { variant: "main", children: [
|
|
1154
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Header_default, { originalProductPrice: formatedOriginalProductPrice || 0 }),
|
|
1155
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Container_default, { variant: "simple", children: [
|
|
1156
|
+
state === "isEmpty" && !loading && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Form_default, { setLoading }),
|
|
1157
|
+
state === "isEmpty" && loading && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Loading_default, {}),
|
|
1158
|
+
state === "isInvalid" && !loading && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SecurityNumberInvalid_default, {}),
|
|
1159
|
+
state === "isRegistered" && !loading && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SecurityNumberRegitered_default, {}),
|
|
1160
|
+
(state === "isActivated" || state === "isPreview") && !loading && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(BenefitsTable_default, {})
|
|
1072
1161
|
] }),
|
|
1073
|
-
|
|
1074
|
-
state === "isInvalid" && !loading && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SecurityNumberInvalid_default, {}),
|
|
1075
|
-
state === "isRegistered" && !loading && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SecurityNumberRegitered_default, {}),
|
|
1076
|
-
(state === "isActivated" || state === "isPreview") && !loading && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BenefitsTable_default, {})
|
|
1162
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Footer_default, {})
|
|
1077
1163
|
] }),
|
|
1078
|
-
/* @__PURE__ */ (0,
|
|
1079
|
-
] })
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Modal_default, { ID: "ShopperIsNotAuthenticated" })
|
|
1165
|
+
] });
|
|
1080
1166
|
}
|
|
1081
1167
|
var PBM_default = PBM;
|
|
1082
1168
|
// Annotate the CommonJS export names for ESM import in node:
|