@agrada_digital/pbm 0.0.64 → 0.0.66
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.js +55 -184
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -185
- package/dist/index.mjs.map +1 -1
- package/dist-wc/pbm-wc.js +113 -123
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -92,7 +92,7 @@ function Container({
|
|
|
92
92
|
"main",
|
|
93
93
|
{
|
|
94
94
|
className: classNames({
|
|
95
|
-
"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-
|
|
95
|
+
"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-white gap-4 relative": variant === "main",
|
|
96
96
|
"w-full h-auto relative": variant === "simple"
|
|
97
97
|
}),
|
|
98
98
|
"data-testid": "test_id_container",
|
|
@@ -158,6 +158,7 @@ function Footer() {
|
|
|
158
158
|
fetchProductByEan();
|
|
159
159
|
}, [targetProduct?.ean]);
|
|
160
160
|
return /* @__PURE__ */ jsxs2("footer", { className: "w-full h-auto relative", id: "footer_pbm", children: [
|
|
161
|
+
state !== "isActivated" && targetProduct?.informativeMessage && /* @__PURE__ */ jsx3("p", { className: "text-start mb-3 font-semibold text-sm text-amber-500", children: targetProduct?.informativeMessage }),
|
|
161
162
|
/* @__PURE__ */ jsxs2("section", { className: classNames2("flex items-center w-full h-auto gap-4", { "justify-center": industryLogo, "justify-start": !industryLogo }), children: [
|
|
162
163
|
/* @__PURE__ */ jsxs2("section", { className: "w-4/5 h-auto", children: [
|
|
163
164
|
/* @__PURE__ */ jsx3("h3", { className: "text-start font-semibold text-sm", children: "Economize com o benef\xEDcio do laborat\xF3rio." }),
|
|
@@ -174,8 +175,7 @@ function Footer() {
|
|
|
174
175
|
"data-testid": "footer_industry_logo_pbm"
|
|
175
176
|
}
|
|
176
177
|
)
|
|
177
|
-
] })
|
|
178
|
-
state !== "isActivated" && targetProduct?.informativeMessage && /* @__PURE__ */ jsx3("p", { className: "text-start font-semibold text-sm", children: targetProduct?.informativeMessage })
|
|
178
|
+
] })
|
|
179
179
|
] });
|
|
180
180
|
}
|
|
181
181
|
var Footer_default = Footer;
|
|
@@ -212,7 +212,7 @@ import { useState as useState2 } from "react";
|
|
|
212
212
|
|
|
213
213
|
// src/services/benefits-with-document.ts
|
|
214
214
|
import Cookies2 from "js-cookie";
|
|
215
|
-
var BenefitsWithDocument = async ({ document
|
|
215
|
+
var BenefitsWithDocument = async ({ document, products }) => {
|
|
216
216
|
const API_URL = import.meta.env.VITE_API_URL;
|
|
217
217
|
if (!API_URL) {
|
|
218
218
|
throw new Error("API URL is not defined in environment variables");
|
|
@@ -227,7 +227,7 @@ var BenefitsWithDocument = async ({ document: document2, products }) => {
|
|
|
227
227
|
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
228
228
|
"Content-Type": "application/json"
|
|
229
229
|
},
|
|
230
|
-
body: JSON.stringify({ consumer: { document
|
|
230
|
+
body: JSON.stringify({ consumer: { document }, products })
|
|
231
231
|
});
|
|
232
232
|
const dataResponse = await response.json();
|
|
233
233
|
if (!dataResponse.success) {
|
|
@@ -349,7 +349,7 @@ function Form({ setLoading }) {
|
|
|
349
349
|
{
|
|
350
350
|
type: "text",
|
|
351
351
|
className: classNames4(
|
|
352
|
-
"w-full h-8 bg-
|
|
352
|
+
"w-full h-8 bg-gray-100 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",
|
|
353
353
|
{ "outline outline-red-600": errors.securityNumber, "rounded-full": showCoupoField }
|
|
354
354
|
),
|
|
355
355
|
placeholder: "Digite seu CPF aqui...",
|
|
@@ -746,129 +746,41 @@ function Text(props) {
|
|
|
746
746
|
}
|
|
747
747
|
var Text_default = Text;
|
|
748
748
|
|
|
749
|
-
// src/components/
|
|
749
|
+
// src/components/UI/Link/index.tsx
|
|
750
750
|
import classNames7 from "classnames";
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if (iframe) {
|
|
764
|
-
try {
|
|
765
|
-
const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
766
|
-
if (!iframeDoc) {
|
|
767
|
-
setIframeError(true);
|
|
768
|
-
setShowFallback(true);
|
|
769
|
-
}
|
|
770
|
-
} catch (e) {
|
|
771
|
-
setIframeError(true);
|
|
772
|
-
setShowFallback(true);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
}, 2e3);
|
|
776
|
-
return () => clearTimeout(timeout);
|
|
777
|
-
}
|
|
778
|
-
}, [openModal, url]);
|
|
779
|
-
const handleOpenInNewWindow = () => {
|
|
780
|
-
if (url) {
|
|
781
|
-
window.open(url, "_blank", "noopener,noreferrer");
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
return /* @__PURE__ */ jsxs7(
|
|
785
|
-
"main",
|
|
751
|
+
|
|
752
|
+
// src/utils/getParams.ts
|
|
753
|
+
var getParams = (params) => {
|
|
754
|
+
if (params === void 0) return "";
|
|
755
|
+
return "?" + Object.keys(params).map((paramter) => paramter + "=" + params[paramter]).join("&");
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
// src/components/UI/Link/index.tsx
|
|
759
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
760
|
+
function Link(props) {
|
|
761
|
+
return /* @__PURE__ */ jsx11(
|
|
762
|
+
"a",
|
|
786
763
|
{
|
|
764
|
+
...props,
|
|
765
|
+
target: "_blank",
|
|
766
|
+
href: typeof props.href === "string" ? props.href : props.href.pathname + getParams(props.href.param),
|
|
787
767
|
className: classNames7(
|
|
788
|
-
"
|
|
789
|
-
|
|
790
|
-
"opacity-100 pointer-events-auto": openModal,
|
|
791
|
-
"opacity-0 pointer-events-none": !openModal
|
|
792
|
-
}
|
|
768
|
+
"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",
|
|
769
|
+
props.className
|
|
793
770
|
),
|
|
794
|
-
"data-testid": "
|
|
795
|
-
id: "
|
|
796
|
-
children:
|
|
797
|
-
/* @__PURE__ */ jsx11(
|
|
798
|
-
"div",
|
|
799
|
-
{
|
|
800
|
-
className: "bg-black/35 inset-0 absolute",
|
|
801
|
-
onClick: () => {
|
|
802
|
-
setOpenModal(false);
|
|
803
|
-
window.location.reload();
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
),
|
|
807
|
-
/* @__PURE__ */ jsx11("section", { className: "w-4/5 h-auto bg-zinc-800 py-2 px-4 flex items-center justify-end rounded-ss-2xl rounded-se-2xl border-b-2 border-gray-100 z-10", children: /* @__PURE__ */ jsx11(
|
|
808
|
-
"button",
|
|
809
|
-
{
|
|
810
|
-
className: "shadow-2xl cursor-pointer text-white font-bold bg-red-500 w-auto h-auto px-8 py-2 rounded-full",
|
|
811
|
-
"aria-label": "Fechar o modal",
|
|
812
|
-
"data-testid": "test_id_buttonclose",
|
|
813
|
-
onClick: () => {
|
|
814
|
-
setOpenModal(false);
|
|
815
|
-
window.location.reload();
|
|
816
|
-
},
|
|
817
|
-
children: "Fechar"
|
|
818
|
-
}
|
|
819
|
-
) }),
|
|
820
|
-
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: [
|
|
821
|
-
/* @__PURE__ */ jsx11(TriangleAlert, { size: 48, className: "text-yellow-500 mb-4" }),
|
|
822
|
-
/* @__PURE__ */ jsx11("h3", { className: "text-white text-xl font-bold mb-4 text-center", children: "N\xE3o foi poss\xEDvel carregar o conte\xFAdo" }),
|
|
823
|
-
/* @__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." }),
|
|
824
|
-
/* @__PURE__ */ jsxs7(
|
|
825
|
-
"button",
|
|
826
|
-
{
|
|
827
|
-
onClick: handleOpenInNewWindow,
|
|
828
|
-
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",
|
|
829
|
-
children: [
|
|
830
|
-
/* @__PURE__ */ jsx11(ExternalLink, { size: 20 }),
|
|
831
|
-
"Abrir em nova janela"
|
|
832
|
-
]
|
|
833
|
-
}
|
|
834
|
-
)
|
|
835
|
-
] }) : /* @__PURE__ */ jsx11(
|
|
836
|
-
"iframe",
|
|
837
|
-
{
|
|
838
|
-
src: url,
|
|
839
|
-
title,
|
|
840
|
-
width: "80%",
|
|
841
|
-
height: "80%",
|
|
842
|
-
allowFullScreen: true,
|
|
843
|
-
className: "z-10",
|
|
844
|
-
onError: () => {
|
|
845
|
-
setIframeError(true);
|
|
846
|
-
setShowFallback(true);
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
),
|
|
850
|
-
/* @__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: [
|
|
851
|
-
/* @__PURE__ */ jsx11(TriangleAlert, { size: 20, className: "shrink-0 text-red-500 " }),
|
|
852
|
-
/* @__PURE__ */ jsxs7("p", { className: "text-start text-sm text-white", children: [
|
|
853
|
-
/* @__PURE__ */ jsx11("span", { className: "text-red-500 font-semibold text-base mr-1", children: "Aten\xE7\xE3o:" }),
|
|
854
|
-
"Ap\xF3s finalizar os termos de aceite, voc\xEA j\xE1 poder\xE1 fechar essa janela. Pode levar ",
|
|
855
|
-
/* @__PURE__ */ jsx11("strong", { children: "alguns minutos" }),
|
|
856
|
-
" para os seus dados serem aprovados."
|
|
857
|
-
] })
|
|
858
|
-
] })
|
|
859
|
-
]
|
|
771
|
+
"data-testid": "test_id_link",
|
|
772
|
+
id: "link_pbm",
|
|
773
|
+
children: props.children
|
|
860
774
|
}
|
|
861
775
|
);
|
|
862
776
|
}
|
|
863
|
-
var
|
|
777
|
+
var Link_default = Link;
|
|
864
778
|
|
|
865
779
|
// src/components/SecurityNumberInvalid/index.tsx
|
|
866
|
-
import {
|
|
867
|
-
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
780
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
868
781
|
function SecurityNumberInvalid({ textColor }) {
|
|
869
|
-
const [openModal, setOpenModal] = useState5(false);
|
|
870
782
|
const { urlAcceptTerms } = usePBMStore();
|
|
871
|
-
return /* @__PURE__ */
|
|
783
|
+
return /* @__PURE__ */ jsxs7(
|
|
872
784
|
"section",
|
|
873
785
|
{
|
|
874
786
|
"data-testid": "test_id_invalid",
|
|
@@ -878,22 +790,11 @@ function SecurityNumberInvalid({ textColor }) {
|
|
|
878
790
|
/* @__PURE__ */ jsx12(Title_default, { className: "w-full", textColor, children: "CPF n\xE3o cadastrado!" }),
|
|
879
791
|
/* @__PURE__ */ jsx12(Text_default, { className: "w-full", textColor, children: "Por favor, conclua seu cadastro para habilitar os benef\xEDcios deste laborat\xF3rio." }),
|
|
880
792
|
/* @__PURE__ */ jsx12(
|
|
881
|
-
|
|
793
|
+
Link_default,
|
|
882
794
|
{
|
|
883
|
-
|
|
884
|
-
onClick: () => setOpenModal(true),
|
|
885
|
-
id: "button_accept_terms_pbm",
|
|
795
|
+
href: urlAcceptTerms || "",
|
|
886
796
|
children: "Aceitar os termos"
|
|
887
797
|
}
|
|
888
|
-
),
|
|
889
|
-
/* @__PURE__ */ jsx12(
|
|
890
|
-
Iframe_default,
|
|
891
|
-
{
|
|
892
|
-
url: urlAcceptTerms || "",
|
|
893
|
-
title: "Aceitar termos PBM",
|
|
894
|
-
openModal,
|
|
895
|
-
setOpenModal
|
|
896
|
-
}
|
|
897
798
|
)
|
|
898
799
|
]
|
|
899
800
|
}
|
|
@@ -902,52 +803,22 @@ function SecurityNumberInvalid({ textColor }) {
|
|
|
902
803
|
var SecurityNumberInvalid_default = SecurityNumberInvalid;
|
|
903
804
|
|
|
904
805
|
// src/PBM.tsx
|
|
905
|
-
import { useCallback as useCallback2, useEffect as
|
|
906
|
-
|
|
907
|
-
// src/components/UI/Link/index.tsx
|
|
908
|
-
import classNames8 from "classnames";
|
|
909
|
-
|
|
910
|
-
// src/utils/getParams.ts
|
|
911
|
-
var getParams = (params) => {
|
|
912
|
-
if (params === void 0) return "";
|
|
913
|
-
return "?" + Object.keys(params).map((paramter) => paramter + "=" + params[paramter]).join("&");
|
|
914
|
-
};
|
|
915
|
-
|
|
916
|
-
// src/components/UI/Link/index.tsx
|
|
917
|
-
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
918
|
-
function Link(props) {
|
|
919
|
-
return /* @__PURE__ */ jsx13(
|
|
920
|
-
"a",
|
|
921
|
-
{
|
|
922
|
-
...props,
|
|
923
|
-
target: "_blank",
|
|
924
|
-
href: typeof props.href === "string" ? props.href : props.href.pathname + getParams(props.href.param),
|
|
925
|
-
className: classNames8(
|
|
926
|
-
"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",
|
|
927
|
-
props.className
|
|
928
|
-
),
|
|
929
|
-
"data-testid": "test_id_link",
|
|
930
|
-
id: "link_pbm",
|
|
931
|
-
children: props.children
|
|
932
|
-
}
|
|
933
|
-
);
|
|
934
|
-
}
|
|
935
|
-
var Link_default = Link;
|
|
806
|
+
import { useCallback as useCallback2, useEffect as useEffect4, useState as useState4 } from "react";
|
|
936
807
|
|
|
937
808
|
// src/components/SecurityNumberRegitered/index.tsx
|
|
938
|
-
import { jsx as
|
|
809
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
939
810
|
function SecurityNumberRegitered({ textColor }) {
|
|
940
811
|
const { urlRegisterIndustry } = usePBMStore();
|
|
941
|
-
return /* @__PURE__ */
|
|
812
|
+
return /* @__PURE__ */ jsxs8(
|
|
942
813
|
"section",
|
|
943
814
|
{
|
|
944
815
|
"data-testid": "test_id_registered",
|
|
945
816
|
className: "flex items-end justify-center gap-2 w-full h-auto flex-col border-y border-zinc-300 py-6",
|
|
946
817
|
id: "security_number_registered_container_pbm",
|
|
947
818
|
children: [
|
|
948
|
-
/* @__PURE__ */
|
|
949
|
-
/* @__PURE__ */
|
|
950
|
-
/* @__PURE__ */
|
|
819
|
+
/* @__PURE__ */ jsx13(Title_default, { className: "w-full", textColor, children: "CPF n\xE3o habilitado no produto!" }),
|
|
820
|
+
/* @__PURE__ */ jsx13(Text_default, { className: "w-full", textColor, children: "Por favor, conclua seu cadastro para habilitar os benef\xEDcios deste laborat\xF3rio." }),
|
|
821
|
+
/* @__PURE__ */ jsx13(
|
|
951
822
|
Link_default,
|
|
952
823
|
{
|
|
953
824
|
href: urlRegisterIndustry || "",
|
|
@@ -1002,7 +873,7 @@ var GetAuthorization = async ({ clientID }) => {
|
|
|
1002
873
|
|
|
1003
874
|
// src/PBM.tsx
|
|
1004
875
|
import { ArrowRight as ArrowRight2 } from "lucide-react";
|
|
1005
|
-
import { Fragment as Fragment2, jsx as
|
|
876
|
+
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1006
877
|
function PBM({
|
|
1007
878
|
originalProductPrice,
|
|
1008
879
|
clientID,
|
|
@@ -1011,9 +882,9 @@ function PBM({
|
|
|
1011
882
|
const formatedOriginalProductPrice = Number(
|
|
1012
883
|
String(originalProductPrice).replace(",", ".")
|
|
1013
884
|
);
|
|
1014
|
-
const [loading, setLoading] =
|
|
885
|
+
const [loading, setLoading] = useState4(false);
|
|
1015
886
|
const { setState, state, setTargetProduct } = usePBMStore();
|
|
1016
|
-
|
|
887
|
+
useEffect4(() => {
|
|
1017
888
|
if (eanProduct) {
|
|
1018
889
|
setTargetProduct({ ean: eanProduct });
|
|
1019
890
|
}
|
|
@@ -1028,34 +899,34 @@ function PBM({
|
|
|
1028
899
|
console.error("Error fetching authorization:", error);
|
|
1029
900
|
}
|
|
1030
901
|
}, [clientID]);
|
|
1031
|
-
|
|
902
|
+
useEffect4(() => {
|
|
1032
903
|
handleAuthorizationRequest();
|
|
1033
904
|
}, [handleAuthorizationRequest]);
|
|
1034
|
-
return /* @__PURE__ */
|
|
1035
|
-
/* @__PURE__ */
|
|
1036
|
-
/* @__PURE__ */
|
|
1037
|
-
state === "isEmpty" && !loading && /* @__PURE__ */
|
|
1038
|
-
/* @__PURE__ */
|
|
1039
|
-
/* @__PURE__ */
|
|
905
|
+
return /* @__PURE__ */ jsx14("div", { id: "pbm-library-root", children: /* @__PURE__ */ jsxs9(Container_default, { variant: "main", children: [
|
|
906
|
+
/* @__PURE__ */ jsx14(Header_default, { originalProductPrice: formatedOriginalProductPrice || 0 }),
|
|
907
|
+
/* @__PURE__ */ jsxs9(Container_default, { variant: "simple", children: [
|
|
908
|
+
state === "isEmpty" && !loading && /* @__PURE__ */ jsxs9(Fragment2, { children: [
|
|
909
|
+
/* @__PURE__ */ jsx14(Form_default, { setLoading }),
|
|
910
|
+
/* @__PURE__ */ jsxs9(
|
|
1040
911
|
Button_default,
|
|
1041
912
|
{
|
|
1042
913
|
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",
|
|
1043
914
|
onClick: () => setState("isActivated"),
|
|
1044
915
|
id: "check_benefits_button",
|
|
1045
916
|
children: [
|
|
1046
|
-
/* @__PURE__ */
|
|
1047
|
-
/* @__PURE__ */
|
|
917
|
+
/* @__PURE__ */ jsx14("span", { children: "Consultar benef\xEDcios" }),
|
|
918
|
+
/* @__PURE__ */ jsx14(ArrowRight2, { size: 16 })
|
|
1048
919
|
]
|
|
1049
920
|
}
|
|
1050
921
|
)
|
|
1051
922
|
] }),
|
|
1052
|
-
state === "isEmpty" && loading && /* @__PURE__ */
|
|
1053
|
-
state === "isInvalid" && !loading && /* @__PURE__ */
|
|
1054
|
-
state === "isRegistered" && !loading && /* @__PURE__ */
|
|
1055
|
-
state === "isActivated" && !loading && /* @__PURE__ */
|
|
923
|
+
state === "isEmpty" && loading && /* @__PURE__ */ jsx14(Loading_default, {}),
|
|
924
|
+
state === "isInvalid" && !loading && /* @__PURE__ */ jsx14(SecurityNumberInvalid_default, {}),
|
|
925
|
+
state === "isRegistered" && !loading && /* @__PURE__ */ jsx14(SecurityNumberRegitered_default, {}),
|
|
926
|
+
state === "isActivated" && !loading && /* @__PURE__ */ jsx14(BenefitsTable_default, {})
|
|
1056
927
|
] }),
|
|
1057
|
-
/* @__PURE__ */
|
|
1058
|
-
] });
|
|
928
|
+
/* @__PURE__ */ jsx14(Footer_default, {})
|
|
929
|
+
] }) });
|
|
1059
930
|
}
|
|
1060
931
|
var PBM_default = PBM;
|
|
1061
932
|
export {
|