@agrada_digital/pbm 0.0.81 → 0.0.83
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 +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +60 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -30
- package/dist/index.mjs.map +1 -1
- package/dist-wc/pbm-wc.js +83 -80
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4,8 +4,10 @@ interface PBMProps {
|
|
|
4
4
|
originalProductPrice: number | string;
|
|
5
5
|
clientID: string;
|
|
6
6
|
eanProduct: string;
|
|
7
|
+
isAuthenticatedShopper: boolean;
|
|
8
|
+
customLoginUrl?: string;
|
|
7
9
|
}
|
|
8
|
-
declare function PBM({ originalProductPrice, clientID, eanProduct, }: PBMProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
declare function PBM({ originalProductPrice, clientID, eanProduct, isAuthenticatedShopper, customLoginUrl, }: PBMProps): react_jsx_runtime.JSX.Element;
|
|
9
11
|
|
|
10
12
|
interface discountTypes {
|
|
11
13
|
unit: number;
|
|
@@ -22,8 +24,10 @@ interface usePBMTypes {
|
|
|
22
24
|
};
|
|
23
25
|
campaign: "pbm_campaign";
|
|
24
26
|
targetProduct: IProduct | null;
|
|
27
|
+
isAuthenticatedShopper: boolean;
|
|
25
28
|
urlAcceptTerms?: string;
|
|
26
29
|
urlRegisterIndustry?: string;
|
|
30
|
+
customLoginUrl?: string;
|
|
27
31
|
}
|
|
28
32
|
interface IProduct {
|
|
29
33
|
ean: string;
|
|
@@ -51,6 +55,8 @@ interface PBMStore extends usePBMTypes {
|
|
|
51
55
|
setTargetProduct: (targetProduct: usePBMTypes["targetProduct"]) => void;
|
|
52
56
|
setUrlAcceptTerms: (urlAcceptTerms: usePBMTypes["urlAcceptTerms"]) => void;
|
|
53
57
|
setUrlRegisterIndustry: (urlRegisterIndustry: usePBMTypes["urlRegisterIndustry"]) => void;
|
|
58
|
+
setIsAuthenticatedShopper: (isAuthenticatedShopper: usePBMTypes["isAuthenticatedShopper"]) => void;
|
|
59
|
+
setCustomLoginUrl: (customLoginUrl: usePBMTypes["customLoginUrl"]) => void;
|
|
54
60
|
}
|
|
55
61
|
declare function usePBMStore(): PBMStore;
|
|
56
62
|
declare function usePBMStore<T>(selector: (state: PBMStore) => T): T;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ interface PBMProps {
|
|
|
4
4
|
originalProductPrice: number | string;
|
|
5
5
|
clientID: string;
|
|
6
6
|
eanProduct: string;
|
|
7
|
+
isAuthenticatedShopper: boolean;
|
|
8
|
+
customLoginUrl?: string;
|
|
7
9
|
}
|
|
8
|
-
declare function PBM({ originalProductPrice, clientID, eanProduct, }: PBMProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
declare function PBM({ originalProductPrice, clientID, eanProduct, isAuthenticatedShopper, customLoginUrl, }: PBMProps): react_jsx_runtime.JSX.Element;
|
|
9
11
|
|
|
10
12
|
interface discountTypes {
|
|
11
13
|
unit: number;
|
|
@@ -22,8 +24,10 @@ interface usePBMTypes {
|
|
|
22
24
|
};
|
|
23
25
|
campaign: "pbm_campaign";
|
|
24
26
|
targetProduct: IProduct | null;
|
|
27
|
+
isAuthenticatedShopper: boolean;
|
|
25
28
|
urlAcceptTerms?: string;
|
|
26
29
|
urlRegisterIndustry?: string;
|
|
30
|
+
customLoginUrl?: string;
|
|
27
31
|
}
|
|
28
32
|
interface IProduct {
|
|
29
33
|
ean: string;
|
|
@@ -51,6 +55,8 @@ interface PBMStore extends usePBMTypes {
|
|
|
51
55
|
setTargetProduct: (targetProduct: usePBMTypes["targetProduct"]) => void;
|
|
52
56
|
setUrlAcceptTerms: (urlAcceptTerms: usePBMTypes["urlAcceptTerms"]) => void;
|
|
53
57
|
setUrlRegisterIndustry: (urlRegisterIndustry: usePBMTypes["urlRegisterIndustry"]) => void;
|
|
58
|
+
setIsAuthenticatedShopper: (isAuthenticatedShopper: usePBMTypes["isAuthenticatedShopper"]) => void;
|
|
59
|
+
setCustomLoginUrl: (customLoginUrl: usePBMTypes["customLoginUrl"]) => void;
|
|
54
60
|
}
|
|
55
61
|
declare function usePBMStore(): PBMStore;
|
|
56
62
|
declare function usePBMStore<T>(selector: (state: PBMStore) => T): T;
|
package/dist/index.js
CHANGED
|
@@ -51,7 +51,9 @@ var initialPBMState = {
|
|
|
51
51
|
grossPrice: 0
|
|
52
52
|
},
|
|
53
53
|
targetProduct: null,
|
|
54
|
-
campaign: "pbm_campaign"
|
|
54
|
+
campaign: "pbm_campaign",
|
|
55
|
+
isAuthenticatedShopper: false,
|
|
56
|
+
customLoginUrl: "/login"
|
|
55
57
|
};
|
|
56
58
|
var createPBMStore = (set) => ({
|
|
57
59
|
...initialPBMState,
|
|
@@ -60,7 +62,9 @@ var createPBMStore = (set) => ({
|
|
|
60
62
|
setTargetProduct: (targetProduct) => set({ targetProduct }),
|
|
61
63
|
setAvailableDiscountSelected: (availableDiscount) => set({ availableDiscountSelected: availableDiscount }),
|
|
62
64
|
setUrlAcceptTerms: (urlAcceptTerms) => set({ urlAcceptTerms }),
|
|
63
|
-
setUrlRegisterIndustry: (urlRegisterIndustry) => set({ urlRegisterIndustry })
|
|
65
|
+
setUrlRegisterIndustry: (urlRegisterIndustry) => set({ urlRegisterIndustry }),
|
|
66
|
+
setIsAuthenticatedShopper: (isAuthenticatedShopper) => set({ isAuthenticatedShopper }),
|
|
67
|
+
setCustomLoginUrl: (customLoginUrl) => set({ customLoginUrl })
|
|
64
68
|
});
|
|
65
69
|
var pbmStore = (0, import_zustand.createStore)(createPBMStore);
|
|
66
70
|
function usePBMStore(selector) {
|
|
@@ -93,7 +97,7 @@ function Header({ originalProductPrice }) {
|
|
|
93
97
|
targetProduct?.discountMax,
|
|
94
98
|
"% OFF"
|
|
95
99
|
] }),
|
|
96
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "36px", height: "36px", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
97
101
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
98
102
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
99
103
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { id: "SVGRepo_iconCarrier", children: [
|
|
@@ -103,12 +107,20 @@ function Header({ originalProductPrice }) {
|
|
|
103
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" })
|
|
104
108
|
] })
|
|
105
109
|
] }),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "flex flex-col items-start justify-center-safe gap-0", children: [
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "line-through text-sm font-light", children: Number(Price)?.toLocaleString("pt-BR", {
|
|
112
|
+
currency: "BRL",
|
|
113
|
+
currencyDisplay: "symbol",
|
|
114
|
+
currencySign: "standard",
|
|
115
|
+
style: "currency"
|
|
116
|
+
}) }),
|
|
117
|
+
Number(Price - Discount)?.toLocaleString("pt-BR", {
|
|
118
|
+
currency: "BRL",
|
|
119
|
+
currencyDisplay: "symbol",
|
|
120
|
+
currencySign: "standard",
|
|
121
|
+
style: "currency"
|
|
122
|
+
})
|
|
123
|
+
] })
|
|
112
124
|
]
|
|
113
125
|
}
|
|
114
126
|
),
|
|
@@ -486,7 +498,7 @@ var import_react3 = require("react");
|
|
|
486
498
|
var import_classnames6 = __toESM(require("classnames"));
|
|
487
499
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
488
500
|
function Item({ data, onChange, checked }) {
|
|
489
|
-
const { setAvailableDiscountSelected,
|
|
501
|
+
const { setAvailableDiscountSelected, state, isAuthenticatedShopper } = usePBMStore();
|
|
490
502
|
const ID_INPUT = "unity_quantity_" + data.authorizedQuantity;
|
|
491
503
|
const decimalDiscount = data.discountPercentual / 100;
|
|
492
504
|
const unitDiscountValue = data.grossPrice * decimalDiscount;
|
|
@@ -522,9 +534,10 @@ function Item({ data, onChange, checked }) {
|
|
|
522
534
|
htmlFor: ID_INPUT,
|
|
523
535
|
className: (0, import_classnames6.default)(
|
|
524
536
|
"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",
|
|
525
|
-
{ "cursor-not-allowed": state === "isPreview", "cursor-pointer": state === "isActivated" }
|
|
537
|
+
{ "cursor-not-allowed": state === "isPreview" || !isAuthenticatedShopper, "cursor-pointer": state === "isActivated" && isAuthenticatedShopper }
|
|
526
538
|
),
|
|
527
539
|
id: "label_benefits_" + ID_INPUT,
|
|
540
|
+
title: !isAuthenticatedShopper ? "Necess\xE1rio fazer login!" : "",
|
|
528
541
|
children: [
|
|
529
542
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
530
543
|
"input",
|
|
@@ -535,7 +548,7 @@ function Item({ data, onChange, checked }) {
|
|
|
535
548
|
className: "hidden",
|
|
536
549
|
checked,
|
|
537
550
|
onChange,
|
|
538
|
-
disabled: state === "isPreview"
|
|
551
|
+
disabled: state === "isPreview" || !isAuthenticatedShopper
|
|
539
552
|
}
|
|
540
553
|
),
|
|
541
554
|
!checked ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.Badge, { color: "#9f9fa9", size: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.BadgeCheck, { color: "#32b316", size: 20 }),
|
|
@@ -543,8 +556,8 @@ function Item({ data, onChange, checked }) {
|
|
|
543
556
|
data.authorizedQuantity,
|
|
544
557
|
"un"
|
|
545
558
|
] }),
|
|
546
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "ml-auto relative", children: [
|
|
547
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "
|
|
559
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "ml-auto relative gap-2 flex items-center-safe justify-end-safe", children: [
|
|
560
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "text-white -top-4 py-0.5 font-semibold text-xs bg-[#32b316] px-2 w-auto text-nowrap rounded-2xl -right-3", children: [
|
|
548
561
|
discountValue.toLocaleString("pt-BR", {
|
|
549
562
|
currency: "BRL",
|
|
550
563
|
currencyDisplay: "symbol",
|
|
@@ -597,7 +610,7 @@ var CheckBenefistWithoutDocument = async ({ products }) => {
|
|
|
597
610
|
// src/components/BenefitsTable/index.tsx
|
|
598
611
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
599
612
|
function BenefitsTable() {
|
|
600
|
-
const { securityNumber, setState, state, targetProduct } = usePBMStore();
|
|
613
|
+
const { securityNumber, setState, state, targetProduct, customLoginUrl, isAuthenticatedShopper } = usePBMStore();
|
|
601
614
|
const [selectedDiscout, setSelectedDiscount] = (0, import_react4.useState)(null);
|
|
602
615
|
const [loading, setLoading] = (0, import_react4.useState)(true);
|
|
603
616
|
const [benefitsItems, setBenefitsItems] = (0, import_react4.useState)();
|
|
@@ -741,21 +754,32 @@ function BenefitsTable() {
|
|
|
741
754
|
className: "bg-transparent p-0 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
|
|
742
755
|
id: "unauthorized_benefits_button",
|
|
743
756
|
children: [
|
|
744
|
-
"Aten\xE7\xE3o:
|
|
757
|
+
"Aten\xE7\xE3o: N\xE3o \xE9 poss\xEDvel utilizar os benef\xEDcos sem realizar a consulta do CPF e o Login, por favor",
|
|
745
758
|
" ",
|
|
746
759
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "underline", children: "insira seu cpf para utilizar os benef\xEDcios" })
|
|
747
760
|
]
|
|
748
761
|
}
|
|
749
762
|
),
|
|
750
|
-
state === "isActivated" && /* @__PURE__ */ (0, import_jsx_runtime9.
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
763
|
+
state === "isActivated" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
764
|
+
!isAuthenticatedShopper && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
765
|
+
Button_default,
|
|
766
|
+
{
|
|
767
|
+
onClick: () => window.location.href = customLoginUrl || "/login",
|
|
768
|
+
className: "bg-transparent p-0 pl-2 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
|
|
769
|
+
id: "login",
|
|
770
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "underline", children: "Por favor, fa\xE7a o Login para aproveitar os benef\xEDcios!" })
|
|
771
|
+
}
|
|
772
|
+
),
|
|
773
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
774
|
+
Button_default,
|
|
775
|
+
{
|
|
776
|
+
onClick: () => setState("isEmpty"),
|
|
777
|
+
className: "bg-transparent p-0 pl-2 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
|
|
778
|
+
id: "change_security_number",
|
|
779
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "underline", children: "Deseja editar o cpf digitado?" })
|
|
780
|
+
}
|
|
781
|
+
)
|
|
782
|
+
] })
|
|
759
783
|
]
|
|
760
784
|
}
|
|
761
785
|
);
|
|
@@ -936,13 +960,16 @@ var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
|
936
960
|
function PBM({
|
|
937
961
|
originalProductPrice,
|
|
938
962
|
clientID,
|
|
939
|
-
eanProduct
|
|
963
|
+
eanProduct,
|
|
964
|
+
isAuthenticatedShopper,
|
|
965
|
+
customLoginUrl
|
|
940
966
|
}) {
|
|
941
967
|
const formatedOriginalProductPrice = Number(
|
|
942
968
|
String(originalProductPrice).replace(",", ".")
|
|
943
969
|
);
|
|
970
|
+
const [isReady, setIsReady] = (0, import_react5.useState)(false);
|
|
944
971
|
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
945
|
-
const { setState, state, setTargetProduct, targetProduct } = usePBMStore();
|
|
972
|
+
const { setState, state, setTargetProduct, targetProduct, setIsAuthenticatedShopper, setCustomLoginUrl } = usePBMStore();
|
|
946
973
|
const [EanProductExist, setEanProductExist] = (0, import_react5.useState)(true);
|
|
947
974
|
const fetchProductByEan = async () => {
|
|
948
975
|
try {
|
|
@@ -964,9 +991,12 @@ function PBM({
|
|
|
964
991
|
industryLogo: pbm.imageLink ?? void 0,
|
|
965
992
|
ean: eanProduct
|
|
966
993
|
});
|
|
994
|
+
setIsAuthenticatedShopper(isAuthenticatedShopper);
|
|
995
|
+
setCustomLoginUrl(customLoginUrl);
|
|
967
996
|
}
|
|
968
997
|
} catch (error) {
|
|
969
998
|
console.error(error);
|
|
999
|
+
} finally {
|
|
970
1000
|
}
|
|
971
1001
|
};
|
|
972
1002
|
const handleAuthorizationRequest = (0, import_react5.useCallback)(async () => {
|
|
@@ -984,6 +1014,9 @@ function PBM({
|
|
|
984
1014
|
(0, import_react5.useEffect)(() => {
|
|
985
1015
|
handleAuthorizationRequest();
|
|
986
1016
|
}, [handleAuthorizationRequest]);
|
|
1017
|
+
if (!isReady) {
|
|
1018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "rounded-xl w-[556px] h-[358px] bg-zinc-500/20 \n shadow-[0_0_15px_rgba(0,0,0,0.1)] \n hover:shadow-[0_0_30px_rgba(0,0,0,0.3)] \n transition-all duration-500 ease-in-out" });
|
|
1019
|
+
}
|
|
987
1020
|
if (!EanProductExist) {
|
|
988
1021
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { id: "pbm-library-root", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Container_default, { variant: "main", children: [
|
|
989
1022
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Title_default, { children: "Erro ao Aplicar o Benef\xEDcio" }),
|