@agrada_digital/pbm 0.0.111 → 0.0.113
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.css +496 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2418 -862
- package/dist/vanilla.js +31 -31
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,43 @@
|
|
|
1
|
+
// src/schema/validation-schema.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var validationSchema = z.object({
|
|
4
|
+
securityNumber: z.string({
|
|
5
|
+
required_error: "CPF \xE9 obrigat\xF3rio."
|
|
6
|
+
}).refine((doc) => {
|
|
7
|
+
const replacedDoc = doc.replace(/\D/g, "");
|
|
8
|
+
return replacedDoc.length >= 11;
|
|
9
|
+
}, "CPF deve conter no m\xEDnimo 11 caracteres.").refine((doc) => {
|
|
10
|
+
const replacedDoc = doc.replace(/\D/g, "");
|
|
11
|
+
return !!Number(replacedDoc);
|
|
12
|
+
}, "CPF deve conter apenas n\xFAmeros."),
|
|
13
|
+
coupon: z.string({ required_error: "Cupom / ID do Cart\xE3o obrigat\xF3rio." }).optional()
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// src/components/UI/Button/index.tsx
|
|
17
|
+
import classNames from "classnames";
|
|
18
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
function Button(props) {
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
"button",
|
|
22
|
+
{
|
|
23
|
+
...props,
|
|
24
|
+
className: classNames(
|
|
25
|
+
"w-3xs cursor-pointer h-10 rounded-lg text-white text-sm font-semibold transition-colors",
|
|
26
|
+
props.className
|
|
27
|
+
),
|
|
28
|
+
style: { ...props.style },
|
|
29
|
+
children: props.children
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
var Button_default = Button;
|
|
34
|
+
|
|
1
35
|
// src/libs/zustand/usePBM.tsx
|
|
2
36
|
import { createStore } from "zustand";
|
|
3
37
|
import { useStore } from "zustand/react";
|
|
4
38
|
var initialPBMState = {
|
|
5
39
|
securityNumber: "",
|
|
40
|
+
requestId: "",
|
|
6
41
|
cardID: "",
|
|
7
42
|
state: "isEmpty",
|
|
8
43
|
availableDiscountSelected: {
|
|
@@ -22,6 +57,7 @@ var initialPBMState = {
|
|
|
22
57
|
var createPBMStore = (set) => ({
|
|
23
58
|
...initialPBMState,
|
|
24
59
|
setSecurityNumber: (securityNumber) => set({ securityNumber }),
|
|
60
|
+
setRequestId: (requestId) => set({ requestId }),
|
|
25
61
|
setState: (state) => set({ state }),
|
|
26
62
|
setTargetProduct: (targetProduct) => set({ targetProduct }),
|
|
27
63
|
setAvailableDiscountSelected: (availableDiscount) => set({ availableDiscountSelected: availableDiscount }),
|
|
@@ -33,183 +69,20 @@ var createPBMStore = (set) => ({
|
|
|
33
69
|
});
|
|
34
70
|
var pbmStore = createStore(createPBMStore);
|
|
35
71
|
function usePBMStore(selector) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return useStore(pbmStore, (state) => state);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/components/Header/index.tsx
|
|
43
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
44
|
-
function Header({ originalProductPrice }) {
|
|
45
|
-
const { targetProduct } = usePBMStore();
|
|
46
|
-
const Price = targetProduct?.listPrice || originalProductPrice;
|
|
47
|
-
const Discount = Price * ((targetProduct?.discountMax || 0) / 100);
|
|
48
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
49
|
-
targetProduct?.informativeMessage && /* @__PURE__ */ jsx("span", { className: "absolute w-11/12 -top-6 bg-emerald-500 px-4 py-1 rounded-lg text-sm text-center font-medium text-white", style: { backgroundColor: "var(--pbm-primary)" }, children: targetProduct?.informativeMessage }),
|
|
50
|
-
/* @__PURE__ */ jsxs(
|
|
51
|
-
"header",
|
|
52
|
-
{
|
|
53
|
-
className: "flex items-center justify-between w-full p-0.5 rounded-xl mt-5",
|
|
54
|
-
style: { backgroundColor: "color-mix(in srgb, var(--pbm-primary), transparent 70%)" },
|
|
55
|
-
id: "header_pbm",
|
|
56
|
-
children: [
|
|
57
|
-
/* @__PURE__ */ jsx(
|
|
58
|
-
"span",
|
|
59
|
-
{
|
|
60
|
-
className: "py-1 px-6 rounded-xl shrink-0 text-white text-xl font-bold flex items-center justify-start gap-2 relative",
|
|
61
|
-
style: { backgroundColor: "var(--pbm-primary)" },
|
|
62
|
-
"data-testid": "test_id_header_price",
|
|
63
|
-
id: "header_price",
|
|
64
|
-
children: /* @__PURE__ */ jsxs("section", { className: "flex items-center gap-2 justify-center-safe", children: [
|
|
65
|
-
/* @__PURE__ */ jsx("span", { className: "line-through text-sm font-light", children: Number(Price)?.toLocaleString("pt-BR", {
|
|
66
|
-
currency: "BRL",
|
|
67
|
-
currencyDisplay: "symbol",
|
|
68
|
-
currencySign: "standard",
|
|
69
|
-
style: "currency"
|
|
70
|
-
}) }),
|
|
71
|
-
Number(Price - Discount)?.toLocaleString("pt-BR", {
|
|
72
|
-
currency: "BRL",
|
|
73
|
-
currencyDisplay: "symbol",
|
|
74
|
-
currencySign: "standard",
|
|
75
|
-
style: "currency"
|
|
76
|
-
})
|
|
77
|
-
] })
|
|
78
|
-
}
|
|
79
|
-
),
|
|
80
|
-
/* @__PURE__ */ jsx("h1", { id: "header_title", className: "text-center w-full font-bold text-xs px-4 md:text-sm", style: { color: "var(--pbm-secondary)" }, children: "Desconto de Laborat\xF3rio" })
|
|
81
|
-
]
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
] });
|
|
85
|
-
}
|
|
86
|
-
var Header_default = Header;
|
|
87
|
-
|
|
88
|
-
// src/components/UI/Container/index.tsx
|
|
89
|
-
import classNames from "classnames";
|
|
90
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
91
|
-
function Container({
|
|
92
|
-
children,
|
|
93
|
-
variant
|
|
94
|
-
}) {
|
|
95
|
-
return /* @__PURE__ */ jsx2(
|
|
96
|
-
"main",
|
|
97
|
-
{
|
|
98
|
-
className: classNames({
|
|
99
|
-
"border-3 border-(--pbm-border) flex flex-col items-center justify-center min-w-(--min-container) max-w-(--max-container) w-full h-auto rounded-xl p-4 bg-white gap-4 relative": variant === "main",
|
|
100
|
-
"w-full h-auto relative": variant === "simple"
|
|
101
|
-
}),
|
|
102
|
-
"data-testid": "test_id_container",
|
|
103
|
-
"data-variant": variant,
|
|
104
|
-
id: "container_pbm",
|
|
105
|
-
children
|
|
106
|
-
}
|
|
72
|
+
return useStore(
|
|
73
|
+
pbmStore,
|
|
74
|
+
selector ?? ((state) => state)
|
|
107
75
|
);
|
|
108
76
|
}
|
|
109
|
-
var Container_default = Container;
|
|
110
|
-
|
|
111
|
-
// src/components/Footer/index.tsx
|
|
112
|
-
import classNames4 from "classnames";
|
|
113
77
|
|
|
114
|
-
// src/components/
|
|
78
|
+
// src/components/Form/index.tsx
|
|
79
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
80
|
+
import { useForm } from "react-hook-form";
|
|
81
|
+
import { ArrowRight } from "lucide-react";
|
|
115
82
|
import classNames2 from "classnames";
|
|
116
|
-
import {
|
|
117
|
-
function Title(props) {
|
|
118
|
-
return /* @__PURE__ */ jsx3(
|
|
119
|
-
"h2",
|
|
120
|
-
{
|
|
121
|
-
className: classNames2(
|
|
122
|
-
"text-start font-semibold text-sm",
|
|
123
|
-
props.className
|
|
124
|
-
),
|
|
125
|
-
style: { color: props.textColor || "var(--pbm-text)", fontSize: props.textSize, textAlign: props.textAlign },
|
|
126
|
-
"data-testid": "test_id_title",
|
|
127
|
-
id: "title_pbm",
|
|
128
|
-
children: props.children
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
var Title_default = Title;
|
|
133
|
-
|
|
134
|
-
// src/components/UI/Text/index.tsx
|
|
135
|
-
import classNames3 from "classnames";
|
|
136
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
137
|
-
function Text(props) {
|
|
138
|
-
return /* @__PURE__ */ jsx4(
|
|
139
|
-
"p",
|
|
140
|
-
{
|
|
141
|
-
className: classNames3(
|
|
142
|
-
"font-normal text-sm",
|
|
143
|
-
props.textAlign && `text-${props.textAlign}`,
|
|
144
|
-
props.className
|
|
145
|
-
),
|
|
146
|
-
style: { color: props.textColor || "var(--pbm-text)", fontSize: props.textSize, textAlign: props.textAlign },
|
|
147
|
-
"data-testid": "test_id_text",
|
|
148
|
-
id: "text_pbm",
|
|
149
|
-
children: props.children
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
var Text_default = Text;
|
|
154
|
-
|
|
155
|
-
// src/components/Footer/index.tsx
|
|
156
|
-
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
157
|
-
function Footer() {
|
|
158
|
-
const { targetProduct } = usePBMStore();
|
|
159
|
-
return /* @__PURE__ */ jsx5("footer", { className: "w-full h-auto relative", id: "footer_pbm", children: /* @__PURE__ */ jsxs2("section", { className: classNames4("flex items-center w-full h-auto gap-4", { "justify-center": targetProduct?.industryLogo, "justify-start": !targetProduct?.industryLogo }), children: [
|
|
160
|
-
/* @__PURE__ */ jsxs2("section", { className: "w-4/5 h-auto", children: [
|
|
161
|
-
/* @__PURE__ */ jsx5(Title_default, { children: "Economize com o benef\xEDcio do laborat\xF3rio." }),
|
|
162
|
-
/* @__PURE__ */ jsx5(Text_default, { children: "Este produto tem pre\xE7o exclusivo para clientes cadastrados no programa." })
|
|
163
|
-
] }),
|
|
164
|
-
targetProduct?.industryLogo && /* @__PURE__ */ jsx5(
|
|
165
|
-
"img",
|
|
166
|
-
{
|
|
167
|
-
src: targetProduct.industryLogo,
|
|
168
|
-
alt: "parceiro",
|
|
169
|
-
className: "w-1/5 min-w-20 h-auto aspect-auto rounded-xl",
|
|
170
|
-
loading: "eager",
|
|
171
|
-
id: "footer_industry_logo_pbm",
|
|
172
|
-
"data-testid": "footer_industry_logo_pbm"
|
|
173
|
-
}
|
|
174
|
-
)
|
|
175
|
-
] }) });
|
|
176
|
-
}
|
|
177
|
-
var Footer_default = Footer;
|
|
178
|
-
|
|
179
|
-
// src/schema/validation-schema.ts
|
|
180
|
-
import { z } from "zod";
|
|
181
|
-
var validationSchema = z.object({
|
|
182
|
-
securityNumber: z.string({
|
|
183
|
-
required_error: "CPF \xE9 obrigat\xF3rio."
|
|
184
|
-
}).refine((doc) => {
|
|
185
|
-
const replacedDoc = doc.replace(/\D/g, "");
|
|
186
|
-
return replacedDoc.length >= 11;
|
|
187
|
-
}, "CPF deve conter no m\xEDnimo 11 caracteres.").refine((doc) => {
|
|
188
|
-
const replacedDoc = doc.replace(/\D/g, "");
|
|
189
|
-
return !!Number(replacedDoc);
|
|
190
|
-
}, "CPF deve conter apenas n\xFAmeros."),
|
|
191
|
-
coupon: z.string({ required_error: "Cupom / ID do Cart\xE3o obrigat\xF3rio." }).optional()
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// src/utils/format-security-number.ts
|
|
195
|
-
var toFormat = (value) => {
|
|
196
|
-
const cleanedValue = value.replace(/\D/g, "");
|
|
197
|
-
if (cleanedValue.length <= 11) {
|
|
198
|
-
return cleanedValue.replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d{1,2})/, "$1-$2").replace(/(-\d{2})\d+?$/, "$1");
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
// src/utils/mapping-internal-states.ts
|
|
203
|
-
var mappingInternalStates = (outContextState) => {
|
|
204
|
-
const status = {
|
|
205
|
-
"acceptance": "isInvalid",
|
|
206
|
-
"industry registration": "isRegistered",
|
|
207
|
-
"active": "isActivated"
|
|
208
|
-
};
|
|
209
|
-
return status[outContextState];
|
|
210
|
-
};
|
|
83
|
+
import { Activity, useState } from "react";
|
|
211
84
|
|
|
212
|
-
// src/services/
|
|
85
|
+
// src/services/lookup-customer.ts
|
|
213
86
|
import Cookies from "js-cookie";
|
|
214
87
|
|
|
215
88
|
// src/services/helper.ts
|
|
@@ -223,75 +96,113 @@ var getEnv = (key) => {
|
|
|
223
96
|
return void 0;
|
|
224
97
|
};
|
|
225
98
|
|
|
226
|
-
// src/services/
|
|
227
|
-
var
|
|
99
|
+
// src/services/lookup-customer.ts
|
|
100
|
+
var LookupCustomer = async ({ DOCUMENT }) => {
|
|
228
101
|
const API_URL = getEnv("VITE_API_URL");
|
|
229
|
-
if (!API_URL) {
|
|
230
|
-
throw new Error("API URL is not defined in environment variables");
|
|
231
|
-
}
|
|
232
102
|
const AUTH_TOKEN = Cookies.get("pbm-token");
|
|
233
103
|
if (!AUTH_TOKEN) {
|
|
234
104
|
throw new Error("Token is not defined in cookies or is expired");
|
|
235
105
|
}
|
|
236
|
-
const response = await fetch(`${API_URL}/
|
|
237
|
-
method: "
|
|
106
|
+
const response = await fetch(`${API_URL}/programregistration/${DOCUMENT}`, {
|
|
107
|
+
method: "GET",
|
|
238
108
|
headers: {
|
|
239
109
|
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
240
110
|
"Content-Type": "application/json"
|
|
241
|
-
}
|
|
242
|
-
body: JSON.stringify({ consumer: { document }, products })
|
|
111
|
+
}
|
|
243
112
|
});
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
113
|
+
if (response.status === 404) {
|
|
114
|
+
return {
|
|
115
|
+
...await response.json(),
|
|
116
|
+
success: false
|
|
117
|
+
};
|
|
247
118
|
}
|
|
119
|
+
const dataResponse = await response.json();
|
|
248
120
|
return dataResponse;
|
|
249
121
|
};
|
|
250
122
|
|
|
251
|
-
// src/
|
|
252
|
-
import classNames5 from "classnames";
|
|
253
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
254
|
-
function Button(props) {
|
|
255
|
-
return /* @__PURE__ */ jsx6(
|
|
256
|
-
"button",
|
|
257
|
-
{
|
|
258
|
-
...props,
|
|
259
|
-
className: classNames5(
|
|
260
|
-
"w-3xs cursor-pointer h-10 rounded-lg text-white text-sm font-semibold transition-colors",
|
|
261
|
-
props.className
|
|
262
|
-
),
|
|
263
|
-
style: { ...props.style },
|
|
264
|
-
children: props.children
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
var Button_default = Button;
|
|
269
|
-
|
|
270
|
-
// src/components/Form/index.tsx
|
|
271
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
272
|
-
import { useForm } from "react-hook-form";
|
|
273
|
-
import { ArrowRight } from "lucide-react";
|
|
274
|
-
import classNames6 from "classnames";
|
|
275
|
-
import { Activity, useState } from "react";
|
|
276
|
-
|
|
277
|
-
// src/libs/zustand/useError.tsx
|
|
123
|
+
// src/libs/zustand/useModal.tsx
|
|
278
124
|
import { create } from "zustand";
|
|
279
|
-
var
|
|
280
|
-
|
|
125
|
+
var initialModalState = {
|
|
126
|
+
modal: {
|
|
127
|
+
id: "",
|
|
128
|
+
open: false,
|
|
129
|
+
label: "",
|
|
130
|
+
url: ""
|
|
131
|
+
}
|
|
281
132
|
};
|
|
282
|
-
var
|
|
283
|
-
...
|
|
284
|
-
|
|
285
|
-
|
|
133
|
+
var createModalStore = (set) => ({
|
|
134
|
+
...initialModalState,
|
|
135
|
+
setModal: (modal) => set({ modal }),
|
|
136
|
+
resetModal: () => set({ modal: initialModalState.modal })
|
|
286
137
|
});
|
|
287
|
-
var
|
|
138
|
+
var useModal = create(createModalStore);
|
|
139
|
+
|
|
140
|
+
// src/utils/formaters.ts
|
|
141
|
+
var formatPhone = (value) => value.replace(/\D/g, "").slice(0, 11).replace(/^(\d{2})(\d{5})(\d{0,4})/, "($1) $2-$3").trim();
|
|
142
|
+
var formatCEP = (value) => value.replace(/\D/g, "").slice(0, 8).replace(/^(\d{5})(\d{0,3})/, "$1-$2");
|
|
143
|
+
var maskCPF = (value) => value.replace(/\D/g, "").replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, "$1.$2.$3-$4");
|
|
144
|
+
var formatPrice = (price) => Number(String(price).replace(",", "."));
|
|
145
|
+
var formaters = {
|
|
146
|
+
phone: (value) => formatPhone(value),
|
|
147
|
+
cep: (value) => formatCEP(value),
|
|
148
|
+
cpf: (value) => maskCPF(value),
|
|
149
|
+
price: (price) => formatPrice(price)
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// src/libs/zustand/usePBMForm.tsx
|
|
153
|
+
import { create as create2 } from "zustand";
|
|
154
|
+
var initialPBMFormState = {
|
|
155
|
+
personalData: { name: "", phone: "", birthday: "", email: "" },
|
|
156
|
+
address: {
|
|
157
|
+
postalcode: "",
|
|
158
|
+
number: "",
|
|
159
|
+
complement: "",
|
|
160
|
+
street: "",
|
|
161
|
+
neighborhood: "",
|
|
162
|
+
city: "",
|
|
163
|
+
stateAddress: ""
|
|
164
|
+
},
|
|
165
|
+
genderResponsibility: { gender: "", patient: null },
|
|
166
|
+
doctor: { typeCredential: "CRM", register: "", state: "", doctorName: "" },
|
|
167
|
+
acceptances: {
|
|
168
|
+
acceptPhone: false,
|
|
169
|
+
acceptsSms: false,
|
|
170
|
+
acceptsEmail: false,
|
|
171
|
+
acceptsMail: false,
|
|
172
|
+
acceptsPrivacyTermsLGPD: false
|
|
173
|
+
},
|
|
174
|
+
step: 0
|
|
175
|
+
};
|
|
176
|
+
var usePBMFormStore = create2((set) => ({
|
|
177
|
+
...initialPBMFormState,
|
|
178
|
+
setPersonalData: (data) => set((s) => ({ personalData: { ...s.personalData, ...data } })),
|
|
179
|
+
setAddress: (data) => set((s) => ({ address: { ...s.address, ...data } })),
|
|
180
|
+
setGenderResponsibility: (data) => set((s) => ({
|
|
181
|
+
genderResponsibility: { ...s.genderResponsibility, ...data }
|
|
182
|
+
})),
|
|
183
|
+
setDoctor: (data) => set((s) => ({ doctor: { ...s.doctor, ...data } })),
|
|
184
|
+
setAcceptances: (data) => set((s) => ({ acceptances: { ...s.acceptances, ...data } })),
|
|
185
|
+
setStep: (step) => set({ step }),
|
|
186
|
+
resetForm: () => set(initialPBMFormState)
|
|
187
|
+
}));
|
|
188
|
+
var usePBMForm = usePBMFormStore;
|
|
189
|
+
|
|
190
|
+
// src/utils/mappingFormStep.ts
|
|
191
|
+
var mappingFormStep = {
|
|
192
|
+
"PersonalData": 0,
|
|
193
|
+
"Address": 1,
|
|
194
|
+
"GenderResponsibility": 2,
|
|
195
|
+
"Doctor": 3,
|
|
196
|
+
"Acceptances": 4
|
|
197
|
+
};
|
|
288
198
|
|
|
289
199
|
// src/components/Form/index.tsx
|
|
290
|
-
import { Fragment
|
|
200
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
291
201
|
function Form({ startTransition }) {
|
|
292
202
|
const store = usePBMStore();
|
|
293
203
|
const [showCardIDField, setShowCardIDField] = useState(false);
|
|
294
|
-
const {
|
|
204
|
+
const { setModal } = useModal();
|
|
205
|
+
const { setStep } = usePBMForm();
|
|
295
206
|
const {
|
|
296
207
|
handleSubmit,
|
|
297
208
|
register,
|
|
@@ -307,89 +218,142 @@ function Form({ startTransition }) {
|
|
|
307
218
|
coupon: ""
|
|
308
219
|
}
|
|
309
220
|
});
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
if (!store.targetProduct.listPrice) {
|
|
321
|
-
console.error("PBMLOG: List Price is not defined!");
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
const product = {
|
|
325
|
-
productId: store.targetProduct.productId,
|
|
326
|
-
ean: store.targetProduct.ean,
|
|
327
|
-
requestedQuantity: 1,
|
|
328
|
-
listPrice: store.targetProduct.listPrice,
|
|
329
|
-
netPrice: store.targetProduct.netPrice ?? store.targetProduct.listPrice
|
|
330
|
-
};
|
|
331
|
-
const response = await BenefitsWithDocument({
|
|
332
|
-
document: values.securityNumber.replace(/\D/g, ""),
|
|
333
|
-
products: [product]
|
|
221
|
+
const CheckCustomerRegisterSteps = ({
|
|
222
|
+
customer
|
|
223
|
+
}) => {
|
|
224
|
+
const data = customer.data;
|
|
225
|
+
if (data.registration?.personal_data === null) {
|
|
226
|
+
setStep(mappingFormStep["PersonalData"]);
|
|
227
|
+
setModal({
|
|
228
|
+
id: "CustomerNotRegistered",
|
|
229
|
+
open: true
|
|
334
230
|
});
|
|
335
|
-
|
|
336
|
-
const status = mappingInternalStates(response.data.product[0].statusCustomer);
|
|
337
|
-
store.setSecurityNumber(values.securityNumber);
|
|
338
|
-
store.setState(status);
|
|
339
|
-
if (status === "isInvalid") {
|
|
340
|
-
store.setUrlAcceptTerms(response.data.product[0].urlAcceptTerm || void 0);
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
if (status === "isRegistered") {
|
|
344
|
-
store.setUrlRegisterIndustry(response.data.product[0].informativeLink);
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (!status) {
|
|
348
|
-
setErrorMessage(response.data.product[0].informativeText);
|
|
349
|
-
store.setState("isError");
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
} catch (error) {
|
|
354
|
-
console.error("PBMLOG: Error validating document -", error);
|
|
231
|
+
return;
|
|
355
232
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
233
|
+
if (data.registration?.address === null) {
|
|
234
|
+
setStep(mappingFormStep["Address"]);
|
|
235
|
+
setModal({
|
|
236
|
+
id: "CustomerNotRegistered",
|
|
237
|
+
open: true
|
|
238
|
+
});
|
|
239
|
+
return;
|
|
360
240
|
}
|
|
361
|
-
if (
|
|
362
|
-
|
|
241
|
+
if (data.registration?.identity_responsibility === null) {
|
|
242
|
+
setStep(mappingFormStep["GenderResponsibility"]);
|
|
243
|
+
setModal({
|
|
244
|
+
id: "CustomerNotRegistered",
|
|
245
|
+
open: true
|
|
246
|
+
});
|
|
247
|
+
return;
|
|
363
248
|
}
|
|
364
|
-
|
|
249
|
+
if (data.registration?.medical_data === null) {
|
|
250
|
+
setStep(mappingFormStep["Doctor"]);
|
|
251
|
+
setModal({
|
|
252
|
+
id: "CustomerNotRegistered",
|
|
253
|
+
open: true
|
|
254
|
+
});
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (data.registration?.lgpd === null) {
|
|
258
|
+
setStep(mappingFormStep["Acceptances"]);
|
|
259
|
+
setModal({
|
|
260
|
+
id: "CustomerNotRegistered",
|
|
261
|
+
open: true
|
|
262
|
+
});
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
store.setState("isActivated");
|
|
266
|
+
};
|
|
267
|
+
const checkSecurityNumberBenefits = async (values) => {
|
|
268
|
+
if (store.targetProduct === null) {
|
|
269
|
+
console.error("PBMLOG: Product is not defined!");
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (!store.targetProduct.productId) {
|
|
273
|
+
console.error("PBMLOG: Product ID is not defined!");
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (!store.targetProduct.listPrice) {
|
|
277
|
+
console.error("PBMLOG: List Price is not defined!");
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
store.setSecurityNumber(values.securityNumber.replace(/\D/g, ""));
|
|
281
|
+
const customerIsRegistered = await LookupCustomer({
|
|
282
|
+
DOCUMENT: values.securityNumber.replace(/\D/g, "")
|
|
283
|
+
});
|
|
284
|
+
if (customerIsRegistered.success) {
|
|
285
|
+
if (!customerIsRegistered.data.requestId) {
|
|
286
|
+
console.error(
|
|
287
|
+
"PBMLOG: Request ID is not defined in lookup customer response"
|
|
288
|
+
);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
store.setRequestId(customerIsRegistered.data.requestId || "");
|
|
292
|
+
CheckCustomerRegisterSteps({ customer: customerIsRegistered });
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (!customerIsRegistered.success) {
|
|
296
|
+
if (!customerIsRegistered.requestId) {
|
|
297
|
+
console.error(
|
|
298
|
+
"PBMLOG: Request ID is not defined in lookup customer response for non registered customer"
|
|
299
|
+
);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
store.setRequestId(customerIsRegistered.requestId || "");
|
|
303
|
+
setModal({
|
|
304
|
+
id: "CustomerNotRegistered",
|
|
305
|
+
open: true
|
|
306
|
+
});
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
const onSubmitDefault = async (values) => {
|
|
311
|
+
if (!store.isAuthenticatedShopper) {
|
|
312
|
+
setModal({ id: "ShopperIsNotAuthenticated", open: true });
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (!showCardIDField) {
|
|
316
|
+
setValue("coupon", void 0, { shouldValidate: false });
|
|
317
|
+
}
|
|
318
|
+
if (showCardIDField && values.coupon != void 0) {
|
|
319
|
+
store.setCardID(values.coupon);
|
|
320
|
+
}
|
|
321
|
+
startTransition(async () => {
|
|
365
322
|
await checkSecurityNumberBenefits(values);
|
|
366
323
|
});
|
|
367
324
|
};
|
|
368
|
-
return /* @__PURE__ */
|
|
369
|
-
/* @__PURE__ */
|
|
325
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
326
|
+
/* @__PURE__ */ jsxs(
|
|
370
327
|
"form",
|
|
371
328
|
{
|
|
372
329
|
onSubmit: handleSubmit(onSubmitDefault),
|
|
373
|
-
className:
|
|
374
|
-
"w-full h-auto flex items-
|
|
375
|
-
{ "mb-4": errors.securityNumber || errors.coupon && showCardIDField, "gap-2": showCardIDField }
|
|
330
|
+
className: classNames2(
|
|
331
|
+
"w-full h-auto flex items-start justify-center flex-col mb-2 transition-all duration-150"
|
|
376
332
|
),
|
|
377
333
|
id: "form_security_number_pbm",
|
|
378
334
|
children: [
|
|
379
|
-
/* @__PURE__ */
|
|
335
|
+
/* @__PURE__ */ jsxs(
|
|
380
336
|
"label",
|
|
381
337
|
{
|
|
382
338
|
htmlFor: "cpf",
|
|
383
|
-
className:
|
|
339
|
+
className: classNames2(
|
|
340
|
+
"w-full h-auto flex items-start flex-col justify-center relative py-2 transition-all duration-100",
|
|
341
|
+
{
|
|
342
|
+
"mb-4": errors.securityNumber && !showCardIDField
|
|
343
|
+
}
|
|
344
|
+
),
|
|
384
345
|
id: "label_security_number_pbm",
|
|
385
346
|
children: [
|
|
386
|
-
/* @__PURE__ */
|
|
347
|
+
/* @__PURE__ */ jsx2(
|
|
387
348
|
"input",
|
|
388
349
|
{
|
|
389
350
|
type: "text",
|
|
390
|
-
className:
|
|
391
|
-
"w-full h-10 bg-gray-100 rounded-
|
|
392
|
-
{
|
|
351
|
+
className: classNames2(
|
|
352
|
+
"w-full h-10 bg-gray-100 rounded-lg text-sm font-semibold focus:outline focus:bg-white text-zinc-600 placeholder:text-zinc-600 px-4 placeholder:text-sm placeholder:font-semibold",
|
|
353
|
+
{
|
|
354
|
+
"outline outline-red-600": errors.securityNumber,
|
|
355
|
+
"rounded-lg": showCardIDField
|
|
356
|
+
}
|
|
393
357
|
),
|
|
394
358
|
style: {
|
|
395
359
|
"--tw-outline-color": !errors.securityNumber ? "var(--pbm-secondary)" : void 0
|
|
@@ -399,7 +363,7 @@ function Form({ startTransition }) {
|
|
|
399
363
|
maxLength: 14,
|
|
400
364
|
...register("securityNumber", {
|
|
401
365
|
onChange: (e) => {
|
|
402
|
-
const formatted =
|
|
366
|
+
const formatted = formaters.cpf(e.target.value);
|
|
403
367
|
setValue("securityNumber", formatted, {
|
|
404
368
|
shouldValidate: true
|
|
405
369
|
});
|
|
@@ -409,24 +373,39 @@ function Form({ startTransition }) {
|
|
|
409
373
|
id: "input_security_number_pbm"
|
|
410
374
|
}
|
|
411
375
|
),
|
|
412
|
-
errors.securityNumber && /* @__PURE__ */
|
|
376
|
+
errors.securityNumber && /* @__PURE__ */ jsx2(
|
|
377
|
+
"span",
|
|
378
|
+
{
|
|
379
|
+
className: "text-red-400 text-xs font-semibold absolute -bottom-3 left-2 text-nowrap",
|
|
380
|
+
id: "security_number_form_error",
|
|
381
|
+
children: errors.securityNumber.message
|
|
382
|
+
}
|
|
383
|
+
)
|
|
413
384
|
]
|
|
414
385
|
}
|
|
415
386
|
),
|
|
416
|
-
/* @__PURE__ */
|
|
387
|
+
/* @__PURE__ */ jsx2(Activity, { mode: showCardIDField ? "visible" : "hidden", children: /* @__PURE__ */ jsxs(
|
|
417
388
|
"label",
|
|
418
389
|
{
|
|
419
390
|
htmlFor: "coupon",
|
|
420
|
-
className:
|
|
391
|
+
className: classNames2(
|
|
392
|
+
"w-full h-auto flex items-start flex-col justify-center relative py-2",
|
|
393
|
+
{
|
|
394
|
+
"mt-2": errors.securityNumber
|
|
395
|
+
}
|
|
396
|
+
),
|
|
421
397
|
id: "label_coupon_pbm",
|
|
422
398
|
children: [
|
|
423
|
-
/* @__PURE__ */
|
|
399
|
+
/* @__PURE__ */ jsx2(
|
|
424
400
|
"input",
|
|
425
401
|
{
|
|
426
402
|
type: "text",
|
|
427
|
-
className:
|
|
403
|
+
className: classNames2(
|
|
428
404
|
"w-full h-10 bg-gray-100 rounded-s-lg text-sm font-semibold focus:outline focus:bg-white text-zinc-600 placeholder:text-zinc-600 px-4 placeholder:text-sm placeholder:font-semibold",
|
|
429
|
-
{
|
|
405
|
+
{
|
|
406
|
+
"outline outline-red-600": errors.coupon,
|
|
407
|
+
"rounded-lg": showCardIDField
|
|
408
|
+
}
|
|
430
409
|
),
|
|
431
410
|
style: {
|
|
432
411
|
"--tw-outline-color": !errors.coupon ? "var(--pbm-secondary)" : void 0
|
|
@@ -444,28 +423,37 @@ function Form({ startTransition }) {
|
|
|
444
423
|
id: "input_coupon_pbm"
|
|
445
424
|
}
|
|
446
425
|
),
|
|
447
|
-
errors.coupon && /* @__PURE__ */
|
|
426
|
+
errors.coupon && /* @__PURE__ */ jsx2(
|
|
427
|
+
"span",
|
|
428
|
+
{
|
|
429
|
+
className: "text-red-400 text-xs font-semibold absolute -bottom-3 left-2 text-nowrap",
|
|
430
|
+
id: "coupon_form_error",
|
|
431
|
+
children: errors.coupon.message
|
|
432
|
+
}
|
|
433
|
+
)
|
|
448
434
|
]
|
|
449
435
|
}
|
|
450
436
|
) }),
|
|
451
|
-
/* @__PURE__ */
|
|
437
|
+
/* @__PURE__ */ jsx2(
|
|
452
438
|
"button",
|
|
453
439
|
{
|
|
454
440
|
type: "submit",
|
|
455
|
-
className:
|
|
456
|
-
"w-
|
|
457
|
-
{
|
|
441
|
+
className: classNames2(
|
|
442
|
+
"w-full h-10 rounded-lg flex items-center justify-center cursor-pointer text-sm text-white font-semibold transition-all duration-150",
|
|
443
|
+
{
|
|
444
|
+
"rounded-lg": showCardIDField
|
|
445
|
+
}
|
|
458
446
|
),
|
|
459
447
|
style: { backgroundColor: "var(--pbm-primary)" },
|
|
460
448
|
id: "button_submit_security_number_pbm",
|
|
461
|
-
children:
|
|
449
|
+
children: "Comprar com desconto"
|
|
462
450
|
}
|
|
463
451
|
)
|
|
464
452
|
]
|
|
465
453
|
}
|
|
466
454
|
),
|
|
467
|
-
/* @__PURE__ */
|
|
468
|
-
/* @__PURE__ */
|
|
455
|
+
/* @__PURE__ */ jsxs("section", { className: "flex items-start flex-col gap-2", children: [
|
|
456
|
+
/* @__PURE__ */ jsxs(
|
|
469
457
|
Button_default,
|
|
470
458
|
{
|
|
471
459
|
className: "bg-transparent p-0 pl-2 w-auto h-auto underline cursor-pointer hover:bg-transparent flex items-center justify-start gap-1",
|
|
@@ -482,12 +470,21 @@ function Form({ startTransition }) {
|
|
|
482
470
|
},
|
|
483
471
|
id: "check_benefits_button",
|
|
484
472
|
children: [
|
|
485
|
-
/* @__PURE__ */
|
|
486
|
-
/* @__PURE__ */
|
|
473
|
+
/* @__PURE__ */ jsx2("span", { className: "text-start", children: !showCardIDField ? "Possui Cupom / ID do Cart\xE3o?" : "N\xE3o possui Cupom / ID do Cart\xE3o?" }),
|
|
474
|
+
/* @__PURE__ */ jsx2(
|
|
475
|
+
ArrowRight,
|
|
476
|
+
{
|
|
477
|
+
size: 16,
|
|
478
|
+
className: classNames2({
|
|
479
|
+
"rotate-0": !showCardIDField,
|
|
480
|
+
"rotate-180": showCardIDField
|
|
481
|
+
})
|
|
482
|
+
}
|
|
483
|
+
)
|
|
487
484
|
]
|
|
488
485
|
}
|
|
489
486
|
),
|
|
490
|
-
/* @__PURE__ */
|
|
487
|
+
/* @__PURE__ */ jsxs(
|
|
491
488
|
Button_default,
|
|
492
489
|
{
|
|
493
490
|
className: "bg-transparent p-0 pl-2 w-auto h-auto underline cursor-pointer hover:bg-transparent flex items-center justify-start gap-1",
|
|
@@ -497,8 +494,8 @@ function Form({ startTransition }) {
|
|
|
497
494
|
onClick: () => store.setState("isPreview"),
|
|
498
495
|
id: "check_benefits_button",
|
|
499
496
|
children: [
|
|
500
|
-
/* @__PURE__ */
|
|
501
|
-
/* @__PURE__ */
|
|
497
|
+
/* @__PURE__ */ jsx2("span", { children: "Consultar Benef\xEDcios" }),
|
|
498
|
+
/* @__PURE__ */ jsx2(ArrowRight, { size: 16 })
|
|
502
499
|
]
|
|
503
500
|
}
|
|
504
501
|
)
|
|
@@ -507,86 +504,10 @@ function Form({ startTransition }) {
|
|
|
507
504
|
}
|
|
508
505
|
var Form_default = Form;
|
|
509
506
|
|
|
510
|
-
// src/components/UI/Loading/index.tsx
|
|
511
|
-
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
512
|
-
function Loading({ textColor }) {
|
|
513
|
-
return /* @__PURE__ */ jsxs4("main", { className: "flex items-center justify-center gap-4", id: "loading_pbm", children: [
|
|
514
|
-
/* @__PURE__ */ jsx8(
|
|
515
|
-
"div",
|
|
516
|
-
{
|
|
517
|
-
"data-testid": "test_id_spin",
|
|
518
|
-
className: "w-8 h-8 border-4 border-gray-300 rounded-full animate-spin",
|
|
519
|
-
style: { borderTopColor: "var(--pbm-secondary)" },
|
|
520
|
-
id: "loading_spin"
|
|
521
|
-
}
|
|
522
|
-
),
|
|
523
|
-
/* @__PURE__ */ jsx8(
|
|
524
|
-
"p",
|
|
525
|
-
{
|
|
526
|
-
className: "text-sm font-semibold text-start",
|
|
527
|
-
style: { color: textColor || "var(--pbm-text)" },
|
|
528
|
-
id: "loading_label",
|
|
529
|
-
children: "Um momento... estamos verificando seus dados."
|
|
530
|
-
}
|
|
531
|
-
)
|
|
532
|
-
] });
|
|
533
|
-
}
|
|
534
|
-
var Loading_default = Loading;
|
|
535
|
-
|
|
536
|
-
// src/services/benefits-without-document.ts
|
|
537
|
-
import Cookies2 from "js-cookie";
|
|
538
|
-
var CheckBenefistWithoutDocument = async ({ products }) => {
|
|
539
|
-
const API_URL = getEnv("VITE_API_URL");
|
|
540
|
-
if (!API_URL) {
|
|
541
|
-
throw new Error("API URL is not defined in environment variables");
|
|
542
|
-
}
|
|
543
|
-
const AUTH_TOKEN = Cookies2.get("pbm-token");
|
|
544
|
-
if (!AUTH_TOKEN) {
|
|
545
|
-
throw new Error("Token is not defined in cookies or is expired");
|
|
546
|
-
}
|
|
547
|
-
const response = await fetch(`${API_URL}/products/genericBenefit`, {
|
|
548
|
-
method: "POST",
|
|
549
|
-
headers: {
|
|
550
|
-
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
551
|
-
"Content-Type": "application/json"
|
|
552
|
-
},
|
|
553
|
-
body: JSON.stringify({ products })
|
|
554
|
-
});
|
|
555
|
-
const dataResponse = await response.json();
|
|
556
|
-
if (!dataResponse.success) {
|
|
557
|
-
throw new Error(dataResponse.message || "Failed to fetch benefits without document");
|
|
558
|
-
}
|
|
559
|
-
return dataResponse;
|
|
560
|
-
};
|
|
561
|
-
|
|
562
|
-
// src/components/BenefitsTable/index.tsx
|
|
563
|
-
import { useEffect as useEffect2, useState as useState2, useTransition } from "react";
|
|
564
|
-
|
|
565
|
-
// src/libs/zustand/useModal.tsx
|
|
566
|
-
import { create as create2 } from "zustand";
|
|
567
|
-
var initialModalState = {
|
|
568
|
-
modal: {
|
|
569
|
-
id: "",
|
|
570
|
-
open: false,
|
|
571
|
-
label: "",
|
|
572
|
-
url: ""
|
|
573
|
-
}
|
|
574
|
-
};
|
|
575
|
-
var createModalStore = (set) => ({
|
|
576
|
-
...initialModalState,
|
|
577
|
-
setModal: (modal) => set({ modal }),
|
|
578
|
-
resetModal: () => set({ modal: initialModalState.modal })
|
|
579
|
-
});
|
|
580
|
-
var useModal = create2(createModalStore);
|
|
581
|
-
|
|
582
|
-
// src/components/BenefitsTable/Item.tsx
|
|
583
|
-
import { useCallback, useEffect } from "react";
|
|
584
|
-
import classNames7 from "classnames";
|
|
585
|
-
|
|
586
507
|
// src/components/UI/Icons/index.tsx
|
|
587
|
-
import { jsx as
|
|
508
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
588
509
|
function CheckON({ size }) {
|
|
589
|
-
return /* @__PURE__ */
|
|
510
|
+
return /* @__PURE__ */ jsx3(
|
|
590
511
|
"svg",
|
|
591
512
|
{
|
|
592
513
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -594,7 +515,7 @@ function CheckON({ size }) {
|
|
|
594
515
|
viewBox: "0 0 500 500",
|
|
595
516
|
width: size,
|
|
596
517
|
height: size,
|
|
597
|
-
children: /* @__PURE__ */
|
|
518
|
+
children: /* @__PURE__ */ jsx3(
|
|
598
519
|
"path",
|
|
599
520
|
{
|
|
600
521
|
d: "M421.44 78.56C375.64 32.77 314.76 7.55 250 7.55S124.36 32.77 78.56 78.56C32.77 124.36 7.55 185.24 7.55 250s25.22 125.64 71.01 171.44c45.8 45.79 106.68 71.01 171.44 71.01s125.64-25.22 171.44-71.01c45.79-45.8 71.01-106.68 71.01-171.44s-25.22-125.64-71.01-171.44zm-49.17 121.7L242.88 334.63c-8.98 9.29-23.57 10.17-33.59 2.02l-79.63-64.7c-10.69-8.67-12.33-24.38-3.66-35.07 8.67-10.69 24.38-12.33 35.07-3.65l61.9 50.39L336.5 165.74c4.4-4.75 10.48-7.59 16.95-7.93a24.88 24.88 0 0118.83 7.26c9.72 9.72 9.71 25.48 0 35.19z",
|
|
@@ -605,7 +526,7 @@ function CheckON({ size }) {
|
|
|
605
526
|
);
|
|
606
527
|
}
|
|
607
528
|
function CheckOFF({ size }) {
|
|
608
|
-
return /* @__PURE__ */
|
|
529
|
+
return /* @__PURE__ */ jsxs2(
|
|
609
530
|
"svg",
|
|
610
531
|
{
|
|
611
532
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -614,8 +535,8 @@ function CheckOFF({ size }) {
|
|
|
614
535
|
width: size,
|
|
615
536
|
height: size,
|
|
616
537
|
children: [
|
|
617
|
-
/* @__PURE__ */
|
|
618
|
-
/* @__PURE__ */
|
|
538
|
+
/* @__PURE__ */ jsx3("circle", { cx: 250, cy: 250, r: 237.45, fill: "#fff" }),
|
|
539
|
+
/* @__PURE__ */ jsx3(
|
|
619
540
|
"path",
|
|
620
541
|
{
|
|
621
542
|
d: "M250 492.45c-64.76 0-125.64-25.22-171.44-71.01C32.77 375.64 7.55 314.76 7.55 250S32.77 124.36 78.56 78.56C124.36 32.77 185.24 7.55 250 7.55s125.64 25.22 171.44 71.01c45.79 45.79 71.01 106.68 71.01 171.44s-25.22 125.64-71.01 171.44c-45.79 45.79-106.68 71.01-171.44 71.01zm0-474.9C121.83 17.55 17.55 121.83 17.55 250S121.83 482.45 250 482.45 482.45 378.17 482.45 250 378.17 17.55 250 17.55z",
|
|
@@ -626,351 +547,2072 @@ function CheckOFF({ size }) {
|
|
|
626
547
|
}
|
|
627
548
|
);
|
|
628
549
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
// src/components/BenefitsTable/Item.tsx
|
|
635
|
-
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
636
|
-
function Item({ data, onChange, checked }) {
|
|
637
|
-
const { setAvailableDiscountSelected, state, isAuthenticatedShopper } = usePBMStore();
|
|
638
|
-
const { setModal } = useModal();
|
|
639
|
-
const ID_INPUT = "unity_quantity_" + data.authorizedQuantity;
|
|
640
|
-
const decimalDiscount = data.discountPercentual / 100;
|
|
641
|
-
const unitDiscountValue = data.grossPrice * decimalDiscount;
|
|
642
|
-
const discountValue = unitDiscountValue * data.authorizedQuantity;
|
|
643
|
-
const totalPriceProductWithDiscountBenefit = data.grossPrice * data.authorizedQuantity - discountValue;
|
|
644
|
-
const updateStorageData = useCallback(() => {
|
|
645
|
-
if (checked) {
|
|
646
|
-
const roundToTwoDecimals = (value) => Math.round(value * 100) / 100;
|
|
647
|
-
setAvailableDiscountSelected({
|
|
648
|
-
discount: {
|
|
649
|
-
total: roundToTwoDecimals(discountValue),
|
|
650
|
-
unit: roundToTwoDecimals(unitDiscountValue)
|
|
651
|
-
},
|
|
652
|
-
quantity: data.authorizedQuantity,
|
|
653
|
-
totalPrice: roundToTwoDecimals(totalPriceProductWithDiscountBenefit),
|
|
654
|
-
grossPrice: data.grossPrice
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
}, [
|
|
658
|
-
checked,
|
|
659
|
-
data.authorizedQuantity,
|
|
660
|
-
setAvailableDiscountSelected,
|
|
661
|
-
discountValue,
|
|
662
|
-
totalPriceProductWithDiscountBenefit,
|
|
663
|
-
unitDiscountValue
|
|
664
|
-
]);
|
|
665
|
-
useEffect(() => {
|
|
666
|
-
updateStorageData();
|
|
667
|
-
}, [updateStorageData]);
|
|
668
|
-
const handleChange = () => {
|
|
669
|
-
if (!isAuthenticatedShopper && state === "isActivated") {
|
|
670
|
-
setModal({
|
|
671
|
-
id: "ShopperIsNotAuthenticated",
|
|
672
|
-
open: true
|
|
673
|
-
});
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
onChange();
|
|
677
|
-
};
|
|
678
|
-
return /* @__PURE__ */ jsxs6(
|
|
679
|
-
"label",
|
|
550
|
+
function Pills({ size, color }) {
|
|
551
|
+
return /* @__PURE__ */ jsxs2(
|
|
552
|
+
"svg",
|
|
680
553
|
{
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
style: {
|
|
687
|
-
borderColor: checked ? "var(--pbm-primary)" : void 0,
|
|
688
|
-
backgroundColor: checked ? "color-mix(in srgb, var(--pbm-primary), transparent 90%)" : void 0
|
|
689
|
-
},
|
|
690
|
-
id: "label_benefits_" + ID_INPUT,
|
|
554
|
+
viewBox: "-0.003 0 99.979 99.979",
|
|
555
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
556
|
+
fill: "#000000",
|
|
557
|
+
width: size,
|
|
558
|
+
height: size,
|
|
691
559
|
children: [
|
|
692
|
-
/* @__PURE__ */
|
|
693
|
-
|
|
560
|
+
/* @__PURE__ */ jsx3("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
561
|
+
/* @__PURE__ */ jsx3(
|
|
562
|
+
"g",
|
|
694
563
|
{
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
className: "hidden",
|
|
699
|
-
checked,
|
|
700
|
-
onChange: handleChange,
|
|
701
|
-
disabled: state === "isPreview"
|
|
564
|
+
id: "SVGRepo_tracerCarrier",
|
|
565
|
+
strokeLinecap: "round",
|
|
566
|
+
strokeLinejoin: "round"
|
|
702
567
|
}
|
|
703
568
|
),
|
|
704
|
-
/* @__PURE__ */
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
"un"
|
|
708
|
-
] }),
|
|
709
|
-
/* @__PURE__ */ jsxs6("section", { className: "ml-auto relative gap-2 flex items-center-safe justify-end-safe", children: [
|
|
710
|
-
/* @__PURE__ */ jsxs6(
|
|
711
|
-
"span",
|
|
569
|
+
/* @__PURE__ */ jsxs2("g", { id: "SVGRepo_iconCarrier", children: [
|
|
570
|
+
/* @__PURE__ */ jsx3(
|
|
571
|
+
"path",
|
|
712
572
|
{
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
573
|
+
fill: "#ffe700",
|
|
574
|
+
d: "M92.869 7.105c9.478 9.476 9.478 24.832 0 34.308L41.411 92.869c-9.475 9.474-24.833 9.474-34.307 0-9.476-9.475-9.476-24.832 0-34.308L58.562 7.105c9.475-9.473 24.834-9.473 34.307 0z"
|
|
575
|
+
}
|
|
576
|
+
),
|
|
577
|
+
/* @__PURE__ */ jsx3(
|
|
578
|
+
"path",
|
|
579
|
+
{
|
|
580
|
+
fill: color,
|
|
581
|
+
d: "M32.548 33.122L7.105 58.563c-9.476 9.476-9.476 24.833 0 34.308 9.474 9.475 24.832 9.475 34.307 0L66.85 67.43 32.548 33.122z"
|
|
582
|
+
}
|
|
583
|
+
),
|
|
584
|
+
/* @__PURE__ */ jsx3(
|
|
585
|
+
"path",
|
|
586
|
+
{
|
|
587
|
+
fill: color,
|
|
588
|
+
d: "M65.43 68.862L31.134 34.568l1.414-1.414 34.294 34.294z"
|
|
589
|
+
}
|
|
590
|
+
),
|
|
591
|
+
/* @__PURE__ */ jsx3(
|
|
592
|
+
"path",
|
|
593
|
+
{
|
|
594
|
+
fill: color,
|
|
595
|
+
d: "M38.096 41.51L12.7 66.906a5.894 5.894 0 0 0 0 8.339 5.896 5.896 0 0 0 8.339 0l25.396-25.396-8.339-8.339z"
|
|
596
|
+
}
|
|
597
|
+
),
|
|
598
|
+
/* @__PURE__ */ jsx3(
|
|
599
|
+
"path",
|
|
600
|
+
{
|
|
601
|
+
fill: "#ffe700",
|
|
602
|
+
d: "M75.244 12.7a5.897 5.897 0 0 0-8.343 0L39.51 40.096l8.339 8.339 27.396-27.396a5.899 5.899 0 0 0-.001-8.339z"
|
|
725
603
|
}
|
|
726
604
|
),
|
|
727
|
-
/* @__PURE__ */
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
605
|
+
/* @__PURE__ */ jsx3(
|
|
606
|
+
"path",
|
|
607
|
+
{
|
|
608
|
+
fill: color,
|
|
609
|
+
d: "M47.862 48.444l-1.414 1.414-8.335-8.336 1.414-1.414z"
|
|
610
|
+
}
|
|
611
|
+
)
|
|
733
612
|
] })
|
|
734
613
|
]
|
|
735
614
|
}
|
|
736
615
|
);
|
|
737
616
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
617
|
+
function ArrowDown({ size, color }) {
|
|
618
|
+
return /* @__PURE__ */ jsxs2(
|
|
619
|
+
"svg",
|
|
620
|
+
{
|
|
621
|
+
viewBox: "0 0 24 24",
|
|
622
|
+
fill: "none",
|
|
623
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
624
|
+
width: size,
|
|
625
|
+
height: size,
|
|
626
|
+
children: [
|
|
627
|
+
/* @__PURE__ */ jsx3("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
628
|
+
/* @__PURE__ */ jsx3(
|
|
629
|
+
"g",
|
|
630
|
+
{
|
|
631
|
+
id: "SVGRepo_tracerCarrier",
|
|
632
|
+
strokeLinecap: "round",
|
|
633
|
+
strokeLinejoin: "round"
|
|
634
|
+
}
|
|
635
|
+
),
|
|
636
|
+
/* @__PURE__ */ jsx3("g", { id: "SVGRepo_iconCarrier", children: /* @__PURE__ */ jsx3(
|
|
637
|
+
"path",
|
|
638
|
+
{
|
|
639
|
+
d: "M7.33199 16.3154C6.94146 15.9248 6.3083 15.9248 5.91777 16.3154C5.52725 16.7059 5.52725 17.339 5.91777 17.7296L10.5834 22.3952C11.3644 23.1762 12.6308 23.1762 13.4118 22.3952L18.0802 17.7267C18.4707 17.3362 18.4707 16.703 18.0802 16.3125C17.6897 15.922 17.0565 15.922 16.666 16.3125L13 19.9786V2.0001C13 1.44781 12.5523 1.0001 12 1.0001C11.4477 1.0001 11 1.44781 11 2.0001V19.9833L7.33199 16.3154Z",
|
|
640
|
+
fill: color
|
|
641
|
+
}
|
|
642
|
+
) })
|
|
643
|
+
]
|
|
751
644
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
var Icons = {
|
|
648
|
+
CheckON,
|
|
649
|
+
CheckOFF,
|
|
650
|
+
Pills,
|
|
651
|
+
ArrowDown
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
// src/components/Header/index.tsx
|
|
655
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
656
|
+
function Header({ originalProductPrice }) {
|
|
657
|
+
const { targetProduct } = usePBMStore();
|
|
658
|
+
const Price = targetProduct?.listPrice || originalProductPrice;
|
|
659
|
+
const Discount = Price * ((targetProduct?.discountMax || 0) / 100);
|
|
660
|
+
return /* @__PURE__ */ jsxs3(
|
|
661
|
+
"header",
|
|
662
|
+
{
|
|
663
|
+
className: "flex items-start justify-start flex-col gap-4 w-full p-0.5 rounded-xl mt-5",
|
|
664
|
+
id: "header_pbm",
|
|
665
|
+
children: [
|
|
666
|
+
/* @__PURE__ */ jsxs3("label", { className: "flex items-center gap-2 cursor-pointer", children: [
|
|
667
|
+
/* @__PURE__ */ jsx4("input", { type: "checkbox", name: "option", className: "peer hidden" }),
|
|
668
|
+
/* @__PURE__ */ jsx4("div", { className: "w-5 h-5 border border-(--pbm-primary) rounded-full flex items-center justify-center transition-all duration-300 after:content-[''] after:w-2 after:h-2 after:rounded-full after:bg-(--pbm-primary) after:scale-0 after:transition-transform after:duration-200 peer-checked:after:scale-100" }),
|
|
669
|
+
/* @__PURE__ */ jsx4("p", { className: "font-medium text-(--pbm-primary) select-none text-sm", children: "Desconto de Laborat\xF3rio" }),
|
|
670
|
+
/* @__PURE__ */ jsx4(Icons.Pills, { size: 16, color: "var(--pbm-primary)" })
|
|
671
|
+
] }),
|
|
672
|
+
/* @__PURE__ */ jsx4(
|
|
673
|
+
"span",
|
|
674
|
+
{
|
|
675
|
+
className: "py-1 rounded-xl shrink-0 text-white text-xl font-bold flex items-center justify-start gap-2 relative",
|
|
676
|
+
"data-testid": "test_id_header_price",
|
|
677
|
+
id: "header_price",
|
|
678
|
+
children: /* @__PURE__ */ jsxs3("section", { className: "flex items-start gap-2 justify-center-safe flex-col", children: [
|
|
679
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center-safe justify-start gap-1", children: [
|
|
680
|
+
/* @__PURE__ */ jsx4("span", { className: "line-through text-sm font-light text-zinc-600", children: Number(Price)?.toLocaleString("pt-BR", {
|
|
681
|
+
currency: "BRL",
|
|
682
|
+
currencyDisplay: "symbol",
|
|
683
|
+
currencySign: "standard",
|
|
684
|
+
style: "currency"
|
|
685
|
+
}) }),
|
|
686
|
+
/* @__PURE__ */ jsx4(Icons.ArrowDown, { size: 14, color: "var(--pbm-primary)" }),
|
|
687
|
+
/* @__PURE__ */ jsxs3("span", { className: "font-semibold text-sm text-(--pbm-primary)", children: [
|
|
688
|
+
(targetProduct?.discountMax || 0).toFixed(2),
|
|
689
|
+
"%"
|
|
690
|
+
] })
|
|
691
|
+
] }),
|
|
692
|
+
/* @__PURE__ */ jsx4("span", { className: "text-lg text-zinc-700 font-bold", children: Number(Price - Discount)?.toLocaleString("pt-BR", {
|
|
693
|
+
currency: "BRL",
|
|
694
|
+
currencyDisplay: "symbol",
|
|
695
|
+
currencySign: "standard",
|
|
696
|
+
style: "currency"
|
|
697
|
+
}) }),
|
|
698
|
+
targetProduct?.informativeMessage && /* @__PURE__ */ jsx4("span", { className: "text-xs text-zinc-600 font-medium", children: targetProduct?.informativeMessage })
|
|
699
|
+
] })
|
|
700
|
+
}
|
|
701
|
+
)
|
|
702
|
+
]
|
|
703
|
+
}
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
var Header_default = Header;
|
|
707
|
+
|
|
708
|
+
// src/components/Iframe/index.tsx
|
|
709
|
+
import classNames5 from "classnames";
|
|
710
|
+
import { TriangleAlert, ExternalLink } from "lucide-react";
|
|
711
|
+
import { useState as useState2, useEffect } from "react";
|
|
712
|
+
|
|
713
|
+
// src/components/UI/Title/index.tsx
|
|
714
|
+
import classNames3 from "classnames";
|
|
715
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
716
|
+
function Title(props) {
|
|
717
|
+
return /* @__PURE__ */ jsx5(
|
|
718
|
+
"h2",
|
|
719
|
+
{
|
|
720
|
+
className: classNames3(
|
|
721
|
+
"text-start font-semibold text-sm",
|
|
722
|
+
props.className
|
|
723
|
+
),
|
|
724
|
+
style: { color: props.textColor || "var(--pbm-text)", fontSize: props.textSize, textAlign: props.textAlign },
|
|
725
|
+
"data-testid": "test_id_title",
|
|
726
|
+
id: "title_pbm",
|
|
727
|
+
children: props.children
|
|
728
|
+
}
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
var Title_default = Title;
|
|
732
|
+
|
|
733
|
+
// src/components/UI/Text/index.tsx
|
|
734
|
+
import classNames4 from "classnames";
|
|
735
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
736
|
+
function Text(props) {
|
|
737
|
+
return /* @__PURE__ */ jsx6(
|
|
738
|
+
"p",
|
|
739
|
+
{
|
|
740
|
+
className: classNames4(
|
|
741
|
+
"font-normal text-sm",
|
|
742
|
+
props.textAlign && `text-${props.textAlign}`,
|
|
743
|
+
props.className
|
|
744
|
+
),
|
|
745
|
+
style: { color: props.textColor || "var(--pbm-text)", fontSize: props.textSize, textAlign: props.textAlign },
|
|
746
|
+
"data-testid": "test_id_text",
|
|
747
|
+
id: "text_pbm",
|
|
748
|
+
children: props.children
|
|
749
|
+
}
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
var Text_default = Text;
|
|
753
|
+
|
|
754
|
+
// src/components/Iframe/index.tsx
|
|
755
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
756
|
+
function Iframe() {
|
|
757
|
+
const [showFallback, setShowFallback] = useState2(false);
|
|
758
|
+
const { setState } = usePBMStore();
|
|
759
|
+
const { resetModal, modal } = useModal();
|
|
760
|
+
const isOpen = modal.open && modal.id === "iframe_pbm";
|
|
761
|
+
useEffect(() => {
|
|
762
|
+
if (isOpen) {
|
|
763
|
+
setShowFallback(false);
|
|
764
|
+
}
|
|
765
|
+
}, [isOpen, modal.url]);
|
|
766
|
+
const handleOpenInNewWindow = () => {
|
|
767
|
+
if (modal.url) {
|
|
768
|
+
window.open(modal.url, "_blank", "noopener,noreferrer");
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
const handleClose = () => {
|
|
772
|
+
setState("isEmpty");
|
|
773
|
+
resetModal();
|
|
774
|
+
};
|
|
775
|
+
if (!modal.url) return;
|
|
776
|
+
return /* @__PURE__ */ jsxs4(
|
|
777
|
+
"main",
|
|
778
|
+
{
|
|
779
|
+
className: classNames5(
|
|
780
|
+
"fixed inset-0 flex items-center justify-center z-50 flex-col transition-all duration-300 pt-[10%]",
|
|
781
|
+
isOpen ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
|
|
782
|
+
),
|
|
783
|
+
id: "iframe_pbm",
|
|
784
|
+
children: [
|
|
785
|
+
/* @__PURE__ */ jsx7(
|
|
786
|
+
"div",
|
|
787
|
+
{
|
|
788
|
+
className: "bg-black/40 inset-0 absolute backdrop-blur-sm",
|
|
789
|
+
onClick: handleClose
|
|
790
|
+
}
|
|
791
|
+
),
|
|
792
|
+
/* @__PURE__ */ jsxs4("section", { className: "w-[90%] md:w-4/5 gap-4 h-auto bg-zinc-900 py-3 px-6 flex items-center justify-end rounded-t-2xl border-b border-white/10 z-10 shadow-2xl", children: [
|
|
793
|
+
/* @__PURE__ */ jsx7(
|
|
794
|
+
Button_default,
|
|
795
|
+
{
|
|
796
|
+
onClick: handleClose,
|
|
797
|
+
className: "bg-red-500 hover:bg-red-400 w-auto px-6 h-9 transition-all active:scale-95 shadow-lg text-xs md:text-sm",
|
|
798
|
+
children: "Cancelar"
|
|
799
|
+
}
|
|
800
|
+
),
|
|
801
|
+
/* @__PURE__ */ jsx7(
|
|
802
|
+
Button_default,
|
|
803
|
+
{
|
|
804
|
+
onClick: handleClose,
|
|
805
|
+
className: "bg-blue-600 hover:bg-blue-500 w-auto px-6 h-9 transition-all active:scale-95 shadow-lg text-xs md:text-sm",
|
|
806
|
+
children: "Finalizei o formul\xE1rio"
|
|
807
|
+
}
|
|
808
|
+
)
|
|
809
|
+
] }),
|
|
810
|
+
/* @__PURE__ */ jsx7("div", { className: "w-[90%] md:w-4/5 h-[60vh] bg-zinc-900 z-10 overflow-hidden relative shadow-2xl", children: showFallback ? /* @__PURE__ */ jsxs4("div", { className: "absolute inset-0 flex flex-col items-center justify-center p-8 text-center bg-zinc-900", children: [
|
|
811
|
+
/* @__PURE__ */ jsx7("div", { className: "bg-yellow-500/10 p-4 rounded-full mb-4 animate-pulse", children: /* @__PURE__ */ jsx7(TriangleAlert, { size: 48, className: "text-yellow-500" }) }),
|
|
812
|
+
/* @__PURE__ */ jsx7(Title_default, { textColor: "white", textSize: "20px", textAlign: "center", className: "mb-2", children: "N\xE3o foi poss\xEDvel carregar o conte\xFAdo" }),
|
|
813
|
+
/* @__PURE__ */ jsx7(Text_default, { textColor: "#a1a1aa", textAlign: "center", className: "mb-8 max-w-md", children: "Este conte\xFAdo n\xE3o permite exibi\xE7\xE3o integrada por seguran\xE7a. Clique no bot\xE3o abaixo para concluir em uma nova aba." }),
|
|
814
|
+
/* @__PURE__ */ jsxs4(
|
|
815
|
+
Button_default,
|
|
816
|
+
{
|
|
817
|
+
onClick: handleOpenInNewWindow,
|
|
818
|
+
className: "flex items-center gap-2 w-auto px-8 h-12 shadow-xl shadow-emerald-500/20",
|
|
819
|
+
children: [
|
|
820
|
+
/* @__PURE__ */ jsx7(ExternalLink, { size: 18 }),
|
|
821
|
+
"Abrir em nova janela"
|
|
822
|
+
]
|
|
823
|
+
}
|
|
824
|
+
)
|
|
825
|
+
] }) : /* @__PURE__ */ jsx7(
|
|
826
|
+
"iframe",
|
|
827
|
+
{
|
|
828
|
+
src: modal.url,
|
|
829
|
+
title: modal.label ?? "Conte\xFAdo PBM",
|
|
830
|
+
className: "w-full h-full border-none bg-white animate-fade-in",
|
|
831
|
+
allowFullScreen: true,
|
|
832
|
+
onError: () => setShowFallback(true)
|
|
833
|
+
}
|
|
834
|
+
) }),
|
|
835
|
+
/* @__PURE__ */ jsxs4("section", { className: "w-[90%] md:w-4/5 flex flex-col md:flex-row items-center justify-between gap-3 bg-zinc-900 py-4 px-6 rounded-b-2xl border-t border-white/5 z-10 shadow-2xl", children: [
|
|
836
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
|
|
837
|
+
/* @__PURE__ */ jsx7(TriangleAlert, { size: 18, className: "text-yellow-500 shrink-0" }),
|
|
838
|
+
/* @__PURE__ */ jsxs4(Text_default, { textColor: "white", className: "text-[10px] md:text-xs", children: [
|
|
839
|
+
/* @__PURE__ */ jsx7("span", { className: "text-yellow-500 font-bold mr-1", children: "Importante:" }),
|
|
840
|
+
"Se a p\xE1gina n\xE3o carregar, tente abrir em tela cheia usando o bot\xE3o ao lado."
|
|
841
|
+
] })
|
|
842
|
+
] }),
|
|
843
|
+
/* @__PURE__ */ jsxs4(
|
|
844
|
+
"button",
|
|
845
|
+
{
|
|
846
|
+
onClick: handleOpenInNewWindow,
|
|
847
|
+
className: "text-white/60 hover:text-white text-[11px] underline flex items-center gap-1 transition-colors cursor-pointer",
|
|
848
|
+
children: [
|
|
849
|
+
/* @__PURE__ */ jsx7(ExternalLink, { size: 14 }),
|
|
850
|
+
" Abrir em nova aba"
|
|
851
|
+
]
|
|
852
|
+
}
|
|
853
|
+
)
|
|
854
|
+
] })
|
|
855
|
+
]
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
var Iframe_default = Iframe;
|
|
860
|
+
|
|
861
|
+
// src/components/UI/Loading/index.tsx
|
|
862
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
863
|
+
function Loading({ textColor }) {
|
|
864
|
+
return /* @__PURE__ */ jsxs5("main", { className: "flex items-center justify-center gap-4", id: "loading_pbm", children: [
|
|
865
|
+
/* @__PURE__ */ jsx8(
|
|
866
|
+
"div",
|
|
867
|
+
{
|
|
868
|
+
"data-testid": "test_id_spin",
|
|
869
|
+
className: "w-8 h-8 border-4 border-gray-300 rounded-full animate-spin",
|
|
870
|
+
style: { borderTopColor: "var(--pbm-secondary)" },
|
|
871
|
+
id: "loading_spin"
|
|
872
|
+
}
|
|
873
|
+
),
|
|
874
|
+
/* @__PURE__ */ jsx8(
|
|
875
|
+
"p",
|
|
876
|
+
{
|
|
877
|
+
className: "text-sm font-semibold text-start",
|
|
878
|
+
style: { color: textColor || "var(--pbm-text)" },
|
|
879
|
+
id: "loading_label",
|
|
880
|
+
children: "Um momento... estamos verificando seus dados."
|
|
881
|
+
}
|
|
882
|
+
)
|
|
883
|
+
] });
|
|
884
|
+
}
|
|
885
|
+
var Loading_default = Loading;
|
|
886
|
+
|
|
887
|
+
// src/components/UI/Container/index.tsx
|
|
888
|
+
import classNames6 from "classnames";
|
|
889
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
890
|
+
function Container({
|
|
891
|
+
children,
|
|
892
|
+
variant
|
|
893
|
+
}) {
|
|
894
|
+
return /* @__PURE__ */ jsx9(
|
|
895
|
+
"main",
|
|
896
|
+
{
|
|
897
|
+
className: classNames6({
|
|
898
|
+
"border-3 border-(--pbm-border) flex flex-col items-center justify-center min-w-(--min-container) max-w-(--max-container) w-full h-auto rounded-xl p-4 bg-white gap-4 relative": variant === "main",
|
|
899
|
+
"w-full h-auto relative": variant === "simple"
|
|
900
|
+
}),
|
|
901
|
+
"data-testid": "test_id_container",
|
|
902
|
+
"data-variant": variant,
|
|
903
|
+
id: "container_pbm",
|
|
904
|
+
children
|
|
905
|
+
}
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
var Container_default = Container;
|
|
909
|
+
|
|
910
|
+
// src/services/activate-customer.ts
|
|
911
|
+
import Cookies2 from "js-cookie";
|
|
912
|
+
var ActivateCustomer = async ({ document, requestId, products }) => {
|
|
913
|
+
const API_URL = getEnv("VITE_API_URL");
|
|
914
|
+
if (!API_URL) {
|
|
915
|
+
throw new Error("API URL is not defined in environment variables");
|
|
916
|
+
}
|
|
917
|
+
const AUTH_TOKEN = Cookies2.get("pbm-token");
|
|
918
|
+
if (!AUTH_TOKEN) {
|
|
919
|
+
throw new Error("Token is not defined in cookies or is expired");
|
|
920
|
+
}
|
|
921
|
+
const response = await fetch(`${API_URL}/programregistration/activate`, {
|
|
922
|
+
method: "POST",
|
|
923
|
+
headers: {
|
|
924
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
925
|
+
"Content-Type": "application/json"
|
|
926
|
+
},
|
|
927
|
+
body: JSON.stringify({ document, requestId, products })
|
|
928
|
+
});
|
|
929
|
+
const dataResponse = await response.json();
|
|
930
|
+
if (!dataResponse.success) {
|
|
931
|
+
throw new Error(dataResponse.message || "Failed to fetch document validation");
|
|
932
|
+
}
|
|
933
|
+
return dataResponse;
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
// src/services/benefits-without-document.ts
|
|
937
|
+
import Cookies3 from "js-cookie";
|
|
938
|
+
var CheckBenefistWithoutDocument = async ({ products }) => {
|
|
939
|
+
const API_URL = getEnv("VITE_API_URL");
|
|
940
|
+
if (!API_URL) {
|
|
941
|
+
throw new Error("API URL is not defined in environment variables");
|
|
942
|
+
}
|
|
943
|
+
const AUTH_TOKEN = Cookies3.get("pbm-token");
|
|
944
|
+
if (!AUTH_TOKEN) {
|
|
945
|
+
throw new Error("Token is not defined in cookies or is expired");
|
|
946
|
+
}
|
|
947
|
+
const response = await fetch(`${API_URL}/products/genericBenefit`, {
|
|
948
|
+
method: "POST",
|
|
949
|
+
headers: {
|
|
950
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
951
|
+
"Content-Type": "application/json"
|
|
952
|
+
},
|
|
953
|
+
body: JSON.stringify({ products })
|
|
954
|
+
});
|
|
955
|
+
const dataResponse = await response.json();
|
|
956
|
+
if (!dataResponse.success) {
|
|
957
|
+
throw new Error(dataResponse.message || "Failed to fetch benefits without document");
|
|
958
|
+
}
|
|
959
|
+
return dataResponse;
|
|
960
|
+
};
|
|
961
|
+
|
|
962
|
+
// src/components/BenefitsTable/index.tsx
|
|
963
|
+
import { useEffect as useEffect3, useState as useState3, useTransition } from "react";
|
|
964
|
+
|
|
965
|
+
// src/components/BenefitsTable/Item.tsx
|
|
966
|
+
import { useCallback, useEffect as useEffect2 } from "react";
|
|
967
|
+
import classNames7 from "classnames";
|
|
968
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
969
|
+
function Item({ data, onChange, checked }) {
|
|
970
|
+
const { setAvailableDiscountSelected, state, isAuthenticatedShopper } = usePBMStore();
|
|
971
|
+
const { setModal } = useModal();
|
|
972
|
+
const ID_INPUT = "unity_quantity_" + data.authorizedQuantity;
|
|
973
|
+
const decimalDiscount = data.discountPercentual / 100;
|
|
974
|
+
const unitDiscountValue = data.grossPrice * decimalDiscount;
|
|
975
|
+
const discountValue = unitDiscountValue * data.authorizedQuantity;
|
|
976
|
+
const totalPriceProductWithDiscountBenefit = data.grossPrice * data.authorizedQuantity - discountValue;
|
|
977
|
+
const updateStorageData = useCallback(() => {
|
|
978
|
+
if (checked) {
|
|
979
|
+
const roundToTwoDecimals = (value) => Math.round(value * 100) / 100;
|
|
980
|
+
setAvailableDiscountSelected({
|
|
981
|
+
discount: {
|
|
982
|
+
total: roundToTwoDecimals(discountValue),
|
|
983
|
+
unit: roundToTwoDecimals(unitDiscountValue)
|
|
984
|
+
},
|
|
985
|
+
quantity: data.authorizedQuantity,
|
|
986
|
+
totalPrice: roundToTwoDecimals(totalPriceProductWithDiscountBenefit),
|
|
987
|
+
grossPrice: data.grossPrice
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
}, [
|
|
991
|
+
checked,
|
|
992
|
+
data.authorizedQuantity,
|
|
993
|
+
data.grossPrice,
|
|
994
|
+
setAvailableDiscountSelected,
|
|
995
|
+
discountValue,
|
|
996
|
+
totalPriceProductWithDiscountBenefit,
|
|
997
|
+
unitDiscountValue
|
|
998
|
+
]);
|
|
999
|
+
useEffect2(() => {
|
|
1000
|
+
updateStorageData();
|
|
1001
|
+
}, [updateStorageData]);
|
|
1002
|
+
const handleChange = () => {
|
|
1003
|
+
if (!isAuthenticatedShopper && state === "isActivated") {
|
|
1004
|
+
setModal({
|
|
1005
|
+
id: "ShopperIsNotAuthenticated",
|
|
1006
|
+
open: true
|
|
1007
|
+
});
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
onChange();
|
|
1011
|
+
};
|
|
1012
|
+
return /* @__PURE__ */ jsxs6(
|
|
1013
|
+
"label",
|
|
1014
|
+
{
|
|
1015
|
+
htmlFor: ID_INPUT,
|
|
1016
|
+
className: classNames7(
|
|
1017
|
+
"label_benefits w-full flex items-center justify-start bg-zinc-300/60 border border-zinc-400/50 px-4 py-2 transition-colors rounded-lg gap-1",
|
|
1018
|
+
{
|
|
1019
|
+
"cursor-not-allowed": state === "isPreview",
|
|
1020
|
+
"cursor-pointer": state === "isActivated",
|
|
1021
|
+
"opacity-80": !checked && state === "isActivated"
|
|
1022
|
+
}
|
|
1023
|
+
),
|
|
1024
|
+
style: {
|
|
1025
|
+
borderColor: checked ? "var(--pbm-primary)" : void 0,
|
|
1026
|
+
backgroundColor: checked ? "color-mix(in srgb, var(--pbm-primary), transparent 90%)" : void 0
|
|
1027
|
+
},
|
|
1028
|
+
id: "label_benefits_" + ID_INPUT,
|
|
1029
|
+
children: [
|
|
1030
|
+
/* @__PURE__ */ jsx10(
|
|
1031
|
+
"input",
|
|
1032
|
+
{
|
|
1033
|
+
type: "radio",
|
|
1034
|
+
name: "benefits_discount",
|
|
1035
|
+
id: ID_INPUT,
|
|
1036
|
+
className: "hidden",
|
|
1037
|
+
checked,
|
|
1038
|
+
onChange: handleChange,
|
|
1039
|
+
disabled: state === "isPreview"
|
|
1040
|
+
}
|
|
1041
|
+
),
|
|
1042
|
+
/* @__PURE__ */ jsx10("span", { style: { color: "var(--pbm-primary)" }, children: !checked ? /* @__PURE__ */ jsx10(Icons.CheckOFF, { size: 20 }) : /* @__PURE__ */ jsx10(Icons.CheckON, { size: 20 }) }),
|
|
1043
|
+
/* @__PURE__ */ jsxs6(
|
|
1044
|
+
"span",
|
|
1045
|
+
{
|
|
1046
|
+
className: "font-semibold text-sm",
|
|
1047
|
+
style: { color: "var(--pbm-text)" },
|
|
1048
|
+
children: [
|
|
1049
|
+
data.authorizedQuantity,
|
|
1050
|
+
"un"
|
|
1051
|
+
]
|
|
1052
|
+
}
|
|
1053
|
+
),
|
|
1054
|
+
/* @__PURE__ */ jsxs6("section", { className: "ml-auto relative gap-2 flex items-center-safe justify-end-safe", children: [
|
|
1055
|
+
/* @__PURE__ */ jsxs6(
|
|
1056
|
+
"span",
|
|
1057
|
+
{
|
|
1058
|
+
className: "text-white -top-4 py-0.5 font-semibold text-xs px-2 w-auto text-nowrap rounded-2xl -right-3",
|
|
1059
|
+
style: { backgroundColor: "var(--pbm-primary)" },
|
|
1060
|
+
children: [
|
|
1061
|
+
discountValue.toLocaleString("pt-BR", {
|
|
1062
|
+
currency: "BRL",
|
|
1063
|
+
currencyDisplay: "symbol",
|
|
1064
|
+
currencySign: "standard",
|
|
1065
|
+
style: "currency"
|
|
1066
|
+
}),
|
|
1067
|
+
" ",
|
|
1068
|
+
"OFF"
|
|
1069
|
+
]
|
|
1070
|
+
}
|
|
1071
|
+
),
|
|
1072
|
+
/* @__PURE__ */ jsx10(
|
|
1073
|
+
"strong",
|
|
1074
|
+
{
|
|
1075
|
+
className: "font-semibold text-sm text-center",
|
|
1076
|
+
style: { color: "var(--pbm-text)" },
|
|
1077
|
+
children: totalPriceProductWithDiscountBenefit.toLocaleString("pt-BR", {
|
|
1078
|
+
currency: "BRL",
|
|
1079
|
+
currencyDisplay: "symbol",
|
|
1080
|
+
currencySign: "standard",
|
|
1081
|
+
style: "currency"
|
|
1082
|
+
})
|
|
1083
|
+
}
|
|
1084
|
+
)
|
|
1085
|
+
] })
|
|
1086
|
+
]
|
|
1087
|
+
}
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
var Item_default = Item;
|
|
1091
|
+
|
|
1092
|
+
// src/components/BenefitsTable/index.tsx
|
|
1093
|
+
import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1094
|
+
function BenefitsTable() {
|
|
1095
|
+
const [isPending, startTransition] = useTransition();
|
|
1096
|
+
const {
|
|
1097
|
+
securityNumber,
|
|
1098
|
+
setState,
|
|
1099
|
+
state,
|
|
1100
|
+
targetProduct,
|
|
1101
|
+
customLoginUrl,
|
|
1102
|
+
isAuthenticatedShopper,
|
|
1103
|
+
requestId
|
|
1104
|
+
} = usePBMStore();
|
|
1105
|
+
const [selectedDiscout, setSelectedDiscount] = useState3(null);
|
|
1106
|
+
const [benefitsItems, setBenefitsItems] = useState3();
|
|
1107
|
+
useEffect3(() => {
|
|
1108
|
+
if (!targetProduct?.productId) {
|
|
1109
|
+
console.error("PBMLOG: Product ID is not defined on targetProduct");
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
if (!targetProduct.ean) {
|
|
1113
|
+
console.error("PBMLOG: EAN is not defined on targetProduct");
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
if (!targetProduct.listPrice) {
|
|
1117
|
+
console.error("PBMLOG: List Price is not defined on targetProduct");
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
if (!targetProduct.price) {
|
|
1121
|
+
console.error("PBMLOG: Price is not defined on targetProduct");
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
const fetchDicountsWithoutDocument = async () => {
|
|
1125
|
+
try {
|
|
1126
|
+
const data = {
|
|
1127
|
+
productId: Number(targetProduct.productId),
|
|
1128
|
+
ean: targetProduct.ean,
|
|
1129
|
+
requestedQuantity: 1,
|
|
1130
|
+
listPrice: targetProduct.listPrice,
|
|
1131
|
+
netPrice: targetProduct.price
|
|
1132
|
+
};
|
|
1133
|
+
const response = await CheckBenefistWithoutDocument({
|
|
1134
|
+
products: [data]
|
|
1135
|
+
});
|
|
1136
|
+
if (response.success && response.data) {
|
|
1137
|
+
setBenefitsItems(response.data);
|
|
1138
|
+
} else {
|
|
1139
|
+
setBenefitsItems(void 0);
|
|
1140
|
+
}
|
|
1141
|
+
} catch (error) {
|
|
1142
|
+
setBenefitsItems(void 0);
|
|
1143
|
+
console.error(error);
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
const fetchDiscountWithDocument = async () => {
|
|
1147
|
+
if (!securityNumber) {
|
|
1148
|
+
console.error("PBMLOG: Document is not defined");
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
if (!requestId) {
|
|
1152
|
+
console.error("PBMLOG: Request ID is not defined");
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
try {
|
|
1156
|
+
const data = {
|
|
1157
|
+
productId: Number(targetProduct.productId),
|
|
1158
|
+
ean: targetProduct.ean,
|
|
1159
|
+
quantity: 1,
|
|
1160
|
+
listPrice: targetProduct.listPrice
|
|
1161
|
+
};
|
|
1162
|
+
const response = await ActivateCustomer({
|
|
1163
|
+
document: securityNumber,
|
|
1164
|
+
requestId,
|
|
1165
|
+
products: [data]
|
|
1166
|
+
});
|
|
1167
|
+
if (response.success && response.data) {
|
|
1168
|
+
setBenefitsItems(response.data.product);
|
|
1169
|
+
} else {
|
|
1170
|
+
setBenefitsItems(void 0);
|
|
1171
|
+
}
|
|
1172
|
+
} catch (error) {
|
|
1173
|
+
setBenefitsItems(void 0);
|
|
1174
|
+
console.error(error);
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
startTransition(async () => {
|
|
1178
|
+
if (state === "isActivated") {
|
|
1179
|
+
await fetchDiscountWithDocument();
|
|
1180
|
+
} else {
|
|
1181
|
+
await fetchDicountsWithoutDocument();
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
}, []);
|
|
1185
|
+
if (isPending) {
|
|
1186
|
+
return /* @__PURE__ */ jsx11(Loading_default, { textColor: "var(--pbm-text)" });
|
|
1187
|
+
}
|
|
1188
|
+
if (benefitsItems?.length && benefitsItems[0]?.statusCode == null && state === "isActivated") {
|
|
1189
|
+
return /* @__PURE__ */ jsx11("main", { className: "flex items-center justify-center gap-4", id: "loading_pbm", children: /* @__PURE__ */ jsx11(
|
|
1190
|
+
"p",
|
|
1191
|
+
{
|
|
1192
|
+
className: "text-sm font-semibold text-start",
|
|
1193
|
+
style: { color: "var(--pbm-text)" },
|
|
1194
|
+
id: "benefits_error_handle",
|
|
1195
|
+
children: benefitsItems[0].informativeText
|
|
1196
|
+
}
|
|
1197
|
+
) });
|
|
1198
|
+
}
|
|
1199
|
+
return /* @__PURE__ */ jsxs7(
|
|
1200
|
+
"section",
|
|
1201
|
+
{
|
|
1202
|
+
className: "flex items-start justify-center gap-4 w-full h-auto flex-col",
|
|
1203
|
+
id: "benefits_table_pbm",
|
|
1204
|
+
children: [
|
|
1205
|
+
/* @__PURE__ */ jsx11(Title_default, { children: "Descontos dispon\xEDveis:" }),
|
|
1206
|
+
/* @__PURE__ */ jsxs7(
|
|
1207
|
+
"form",
|
|
1208
|
+
{
|
|
1209
|
+
className: "flex flex-col items-center justify-start w-full gap-4.5",
|
|
1210
|
+
id: "form_benefits_table_pbm",
|
|
1211
|
+
onSubmit: (e) => e.preventDefault(),
|
|
1212
|
+
children: [
|
|
1213
|
+
!benefitsItems && /* @__PURE__ */ jsx11(
|
|
1214
|
+
"p",
|
|
1215
|
+
{
|
|
1216
|
+
className: "text-sm font-semibold text-start text-zinc-900",
|
|
1217
|
+
id: "benefits_empty_pbm",
|
|
1218
|
+
children: "N\xE3o foi poss\xEDvel encontrar benef\xEDcios para esse produto."
|
|
1219
|
+
}
|
|
1220
|
+
),
|
|
1221
|
+
benefitsItems && benefitsItems.map((item, index) => {
|
|
1222
|
+
const ID_INPUT = "unity_quantity_" + item.authorizedQuantity;
|
|
1223
|
+
return /* @__PURE__ */ jsx11(
|
|
1224
|
+
Item_default,
|
|
1225
|
+
{
|
|
1226
|
+
data: item,
|
|
1227
|
+
checked: selectedDiscout === ID_INPUT,
|
|
1228
|
+
onChange: () => setSelectedDiscount(ID_INPUT)
|
|
1229
|
+
},
|
|
1230
|
+
index
|
|
1231
|
+
);
|
|
1232
|
+
})
|
|
1233
|
+
]
|
|
1234
|
+
}
|
|
1235
|
+
),
|
|
1236
|
+
state === "isPreview" && /* @__PURE__ */ jsxs7(
|
|
1237
|
+
Button_default,
|
|
1238
|
+
{
|
|
1239
|
+
onClick: () => setState("isEmpty"),
|
|
1240
|
+
className: "bg-transparent p-0 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
|
|
1241
|
+
id: "unauthorized_benefits_button",
|
|
1242
|
+
children: [
|
|
1243
|
+
"Aten\xE7\xE3o: N\xE3o \xE9 poss\xEDvel utilizar os benef\xEDcos sem realizar a consulta do CPF e o Login, por favor",
|
|
1244
|
+
" ",
|
|
1245
|
+
/* @__PURE__ */ jsx11("span", { className: "underline", children: "insira seu cpf para utilizar os benef\xEDcios" })
|
|
1246
|
+
]
|
|
1247
|
+
}
|
|
1248
|
+
),
|
|
1249
|
+
state === "isActivated" && /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
1250
|
+
!isAuthenticatedShopper && /* @__PURE__ */ jsx11(
|
|
1251
|
+
Button_default,
|
|
1252
|
+
{
|
|
1253
|
+
type: "button",
|
|
1254
|
+
onClick: () => window.location.assign(customLoginUrl || "/login"),
|
|
1255
|
+
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",
|
|
1256
|
+
id: "login",
|
|
1257
|
+
children: /* @__PURE__ */ jsx11("span", { className: "underline", children: "Por favor, fa\xE7a o Login para aproveitar os benef\xEDcios!" })
|
|
1258
|
+
}
|
|
1259
|
+
),
|
|
1260
|
+
/* @__PURE__ */ jsx11(
|
|
1261
|
+
Button_default,
|
|
1262
|
+
{
|
|
1263
|
+
onClick: () => setState("isEmpty"),
|
|
1264
|
+
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",
|
|
1265
|
+
id: "change_security_number",
|
|
1266
|
+
children: /* @__PURE__ */ jsx11("span", { className: "underline", children: "Deseja editar o cpf digitado?" })
|
|
1267
|
+
}
|
|
1268
|
+
)
|
|
1269
|
+
] })
|
|
1270
|
+
]
|
|
1271
|
+
}
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
var BenefitsTable_default = BenefitsTable;
|
|
1275
|
+
|
|
1276
|
+
// src/components/SecurityNumberInvalid/index.tsx
|
|
1277
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1278
|
+
function SecurityNumberInvalid({ textColor }) {
|
|
1279
|
+
const { urlAcceptTerms } = usePBMStore();
|
|
1280
|
+
const { setModal } = useModal();
|
|
1281
|
+
const handleOpenModal = () => {
|
|
1282
|
+
if (!urlAcceptTerms) return;
|
|
1283
|
+
setModal({ open: true, id: "iframe_pbm", label: "Aceitar os termos", url: urlAcceptTerms });
|
|
1284
|
+
};
|
|
1285
|
+
return /* @__PURE__ */ jsxs8(
|
|
1286
|
+
"section",
|
|
1287
|
+
{
|
|
1288
|
+
"data-testid": "test_id_invalid",
|
|
1289
|
+
className: "flex items-end justify-center gap-2 w-full h-auto flex-col border-y py-6",
|
|
1290
|
+
style: { borderColor: "color-mix(in srgb, var(--pbm-text), transparent 80%)" },
|
|
1291
|
+
id: "security_number_invalid_container_pbm",
|
|
1292
|
+
children: [
|
|
1293
|
+
/* @__PURE__ */ jsx12(Title_default, { className: "w-full", textColor, children: "CPF n\xE3o cadastrado." }),
|
|
1294
|
+
/* @__PURE__ */ jsxs8(Text_default, { className: "w-full", textColor, children: [
|
|
1295
|
+
"Conclua seu cadastro para habilitar o benef\xEDcio. ",
|
|
1296
|
+
/* @__PURE__ */ jsx12("br", {}),
|
|
1297
|
+
"Ao clicar em \u201CAceitar os termos\u201D, voc\xEA ir\xE1 para uma p\xE1gina externa. Aceite os termos e volte para continuar."
|
|
1298
|
+
] }),
|
|
1299
|
+
/* @__PURE__ */ jsx12(Button_default, { onClick: () => handleOpenModal(), style: { backgroundColor: "var(--pbm-primary)" }, children: "Aceitar os termos" })
|
|
1300
|
+
]
|
|
1301
|
+
}
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
var SecurityNumberInvalid_default = SecurityNumberInvalid;
|
|
1305
|
+
|
|
1306
|
+
// src/components/SecurityNumberRegitered/index.tsx
|
|
1307
|
+
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1308
|
+
function SecurityNumberRegitered({ textColor }) {
|
|
1309
|
+
const { urlRegisterIndustry } = usePBMStore();
|
|
1310
|
+
const { setModal } = useModal();
|
|
1311
|
+
const handleOpenModal = () => {
|
|
1312
|
+
if (!urlRegisterIndustry) return;
|
|
1313
|
+
setModal({ open: true, id: "iframe_pbm", label: "Ativar CPF", url: urlRegisterIndustry });
|
|
1314
|
+
};
|
|
1315
|
+
return /* @__PURE__ */ jsxs9(
|
|
1316
|
+
"section",
|
|
1317
|
+
{
|
|
1318
|
+
"data-testid": "test_id_registered",
|
|
1319
|
+
className: "flex items-end justify-center gap-2 w-full h-auto flex-col border-y py-6",
|
|
1320
|
+
style: { borderColor: "color-mix(in srgb, var(--pbm-text), transparent 80%)" },
|
|
1321
|
+
id: "security_number_registered_container_pbm",
|
|
1322
|
+
children: [
|
|
1323
|
+
/* @__PURE__ */ jsx13(Title_default, { className: "w-full", textColor, children: "Ops, seu CPF ainda n\xE3o est\xE1 habilitado para este produto." }),
|
|
1324
|
+
/* @__PURE__ */ jsx13(Text_default, { className: "w-full", textColor, children: "Para ativar o benef\xEDcio, clique em \u201CAtivar CPF\u201D e conclua a etapa na p\xE1gina externa. Depois, \xE9 s\xF3 voltar para continuar \u2014 vamos aguardar voc\xEA aqui." }),
|
|
1325
|
+
/* @__PURE__ */ jsx13(Button_default, { onClick: () => handleOpenModal(), style: { backgroundColor: "var(--pbm-primary)" }, children: "Ativar CPF" })
|
|
1326
|
+
]
|
|
1327
|
+
}
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1330
|
+
var SecurityNumberRegitered_default = SecurityNumberRegitered;
|
|
1331
|
+
|
|
1332
|
+
// src/components/Errors/ErrorToApplyBenefits.tsx
|
|
1333
|
+
import { RefreshCw } from "lucide-react";
|
|
1334
|
+
|
|
1335
|
+
// src/libs/zustand/useError.tsx
|
|
1336
|
+
import { create as create3 } from "zustand";
|
|
1337
|
+
var initialErrorState = {
|
|
1338
|
+
ErrorMessage: "Erro ao aplicar o benef\xEDcio"
|
|
1339
|
+
};
|
|
1340
|
+
var createErrorStore = (set) => ({
|
|
1341
|
+
...initialErrorState,
|
|
1342
|
+
setErrorMessage: (ErrorMessage) => set({ ErrorMessage }),
|
|
1343
|
+
resetErrorMessage: () => set({ ErrorMessage: initialErrorState.ErrorMessage })
|
|
1344
|
+
});
|
|
1345
|
+
var useError = create3(createErrorStore);
|
|
1346
|
+
|
|
1347
|
+
// src/components/Errors/ErrorToApplyBenefits.tsx
|
|
1348
|
+
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1349
|
+
var ErrorToApplyBenefits = () => {
|
|
1350
|
+
const { ErrorMessage } = useError();
|
|
1351
|
+
const { setState } = usePBMStore();
|
|
1352
|
+
return /* @__PURE__ */ jsxs10(Container_default, { variant: "main", children: [
|
|
1353
|
+
/* @__PURE__ */ jsx14(Title_default, { children: "Erro ao Aplicar o Benef\xEDcio" }),
|
|
1354
|
+
/* @__PURE__ */ jsx14(Text_default, { textAlign: "center", children: ErrorMessage }),
|
|
1355
|
+
/* @__PURE__ */ jsxs10(
|
|
1356
|
+
Button_default,
|
|
1357
|
+
{
|
|
1358
|
+
className: "bg-transparent p-0 pl-2 w-auto h-auto underline cursor-pointer hover:bg-transparent flex items-center justify-start gap-1",
|
|
1359
|
+
style: { color: "var(--pbm-text)" },
|
|
1360
|
+
onMouseOver: (e) => e.currentTarget.style.filter = "brightness(0.8)",
|
|
1361
|
+
onMouseOut: (e) => e.currentTarget.style.filter = "none",
|
|
1362
|
+
onClick: () => setState("isEmpty"),
|
|
1363
|
+
id: "check_benefits_button",
|
|
1364
|
+
children: [
|
|
1365
|
+
/* @__PURE__ */ jsx14("span", { children: "Tentar novamente" }),
|
|
1366
|
+
/* @__PURE__ */ jsx14(RefreshCw, { size: 16 })
|
|
1367
|
+
]
|
|
1368
|
+
}
|
|
1369
|
+
)
|
|
1370
|
+
] });
|
|
1371
|
+
};
|
|
1372
|
+
var ErrorToApplyBenefits_default = ErrorToApplyBenefits;
|
|
1373
|
+
|
|
1374
|
+
// src/components/Modals/CustomerNotRegistered/index.tsx
|
|
1375
|
+
import { useState as useState9 } from "react";
|
|
1376
|
+
import classNames13 from "classnames";
|
|
1377
|
+
|
|
1378
|
+
// src/components/Modals/CustomerNotRegistered/StepPersonalDataForm.tsx
|
|
1379
|
+
import { useState as useState4 } from "react";
|
|
1380
|
+
|
|
1381
|
+
// src/components/Modals/CustomerNotRegistered/Shared/FieldWrapper.tsx
|
|
1382
|
+
import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1383
|
+
var FieldWrapper = ({
|
|
1384
|
+
label,
|
|
1385
|
+
error,
|
|
1386
|
+
children
|
|
1387
|
+
}) => /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1", children: [
|
|
1388
|
+
/* @__PURE__ */ jsx15("label", { className: "text-xs font-medium text-zinc-500 uppercase tracking-wide", children: label }),
|
|
1389
|
+
children,
|
|
1390
|
+
error && /* @__PURE__ */ jsx15("span", { className: "text-xs text-red-500 mt-0.5", children: error })
|
|
1391
|
+
] });
|
|
1392
|
+
var FieldWrapper_default = FieldWrapper;
|
|
1393
|
+
|
|
1394
|
+
// src/components/Modals/CustomerNotRegistered/Shared/DisabledInputClass.ts
|
|
1395
|
+
var disabledInputClass = "w-full rounded-lg border border-gray-200 bg-gray-100 px-3 py-2.5 text-sm text-gray-400 cursor-not-allowed";
|
|
1396
|
+
var DisabledInputClass_default = disabledInputClass;
|
|
1397
|
+
|
|
1398
|
+
// src/components/Modals/CustomerNotRegistered/Shared/InputClass.ts
|
|
1399
|
+
import classNames8 from "classnames";
|
|
1400
|
+
var inputClass = (error) => classNames8(
|
|
1401
|
+
"w-full rounded-lg border px-3 py-2.5 text-sm text-gray-800 outline-none transition-all",
|
|
1402
|
+
"focus:ring-2 focus:ring-blue-500/30 focus:border-blue-500",
|
|
1403
|
+
error ? "border-red-400 bg-red-50" : "border-gray-200 bg-gray-50 hover:border-gray-300"
|
|
1404
|
+
);
|
|
1405
|
+
var InputClass_default = inputClass;
|
|
1406
|
+
|
|
1407
|
+
// src/components/Modals/CustomerNotRegistered/Shared/StepActions.tsx
|
|
1408
|
+
import classNames9 from "classnames";
|
|
1409
|
+
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1410
|
+
var StepActions = ({
|
|
1411
|
+
onNext,
|
|
1412
|
+
onBack,
|
|
1413
|
+
loading,
|
|
1414
|
+
nextLabel = "Continuar",
|
|
1415
|
+
isLast = false
|
|
1416
|
+
}) => /* @__PURE__ */ jsxs12("div", { className: "flex gap-2 mt-2 pt-4 border-t border-gray-100", children: [
|
|
1417
|
+
onBack && /* @__PURE__ */ jsx16(
|
|
1418
|
+
"button",
|
|
1419
|
+
{
|
|
1420
|
+
type: "button",
|
|
1421
|
+
onClick: onBack,
|
|
1422
|
+
className: "flex-1 rounded-lg border border-gray-200 py-2.5 text-sm font-medium text-zinc-600 hover:bg-zinc-600/10 transition-all cursor-pointer",
|
|
1423
|
+
children: "Voltar"
|
|
1424
|
+
}
|
|
1425
|
+
),
|
|
1426
|
+
/* @__PURE__ */ jsx16(
|
|
1427
|
+
"button",
|
|
1428
|
+
{
|
|
1429
|
+
type: "button",
|
|
1430
|
+
onClick: onNext,
|
|
1431
|
+
disabled: loading,
|
|
1432
|
+
className: classNames9(
|
|
1433
|
+
"flex-2 rounded-lg py-2.5 text-sm font-semibold text-white transition-all cursor-pointer",
|
|
1434
|
+
isLast ? "bg-emerald-600 hover:bg-emerald-500" : "bg-(--pbm-primary) hover:bg-(--pbm-primary)/60",
|
|
1435
|
+
loading && "opacity-60 cursor-not-allowed"
|
|
1436
|
+
),
|
|
1437
|
+
children: loading ? /* @__PURE__ */ jsxs12("span", { className: "flex items-center justify-center gap-2", children: [
|
|
1438
|
+
/* @__PURE__ */ jsxs12("svg", { className: "h-4 w-4 animate-spin", viewBox: "0 0 24 24", fill: "none", children: [
|
|
1439
|
+
/* @__PURE__ */ jsx16(
|
|
1440
|
+
"circle",
|
|
1441
|
+
{
|
|
1442
|
+
className: "opacity-25",
|
|
1443
|
+
cx: "12",
|
|
1444
|
+
cy: "12",
|
|
1445
|
+
r: "10",
|
|
1446
|
+
stroke: "currentColor",
|
|
1447
|
+
strokeWidth: "4"
|
|
1448
|
+
}
|
|
1449
|
+
),
|
|
1450
|
+
/* @__PURE__ */ jsx16(
|
|
1451
|
+
"path",
|
|
1452
|
+
{
|
|
1453
|
+
className: "opacity-75",
|
|
1454
|
+
fill: "currentColor",
|
|
1455
|
+
d: "M4 12a8 8 0 018-8v8z"
|
|
1456
|
+
}
|
|
1457
|
+
)
|
|
1458
|
+
] }),
|
|
1459
|
+
"Enviando..."
|
|
1460
|
+
] }) : nextLabel
|
|
1461
|
+
}
|
|
1462
|
+
)
|
|
1463
|
+
] });
|
|
1464
|
+
var StepActions_default = StepActions;
|
|
1465
|
+
|
|
1466
|
+
// src/services/set-personal-data-form.ts
|
|
1467
|
+
import Cookies4 from "js-cookie";
|
|
1468
|
+
var SetPersonalDataForm = async ({ document, requestId, personalData }) => {
|
|
1469
|
+
const API_URL = getEnv("VITE_API_URL");
|
|
1470
|
+
const AUTH_TOKEN = Cookies4.get("pbm-token");
|
|
1471
|
+
if (!AUTH_TOKEN) {
|
|
1472
|
+
throw new Error("Token is not defined in cookies or is expired");
|
|
1473
|
+
}
|
|
1474
|
+
const response = await fetch(`${API_URL}/programregistration/personalData`, {
|
|
1475
|
+
method: "PUT",
|
|
1476
|
+
headers: {
|
|
1477
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
1478
|
+
"Content-Type": "application/json"
|
|
1479
|
+
},
|
|
1480
|
+
body: JSON.stringify({ document, requestId, ...personalData })
|
|
1481
|
+
});
|
|
1482
|
+
const dataResponse = await response.json();
|
|
1483
|
+
if (!dataResponse.success) {
|
|
1484
|
+
throw new Error(dataResponse.message || "Failed to fetch authorization");
|
|
1485
|
+
}
|
|
1486
|
+
return dataResponse;
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
// src/components/Modals/CustomerNotRegistered/StepPersonalDataForm.tsx
|
|
1490
|
+
import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1491
|
+
var StepPersonalDataForm = ({
|
|
1492
|
+
securityNumber,
|
|
1493
|
+
onNext
|
|
1494
|
+
}) => {
|
|
1495
|
+
const { personalData, setPersonalData, setStep } = usePBMForm();
|
|
1496
|
+
const { setModal } = useModal();
|
|
1497
|
+
const store = usePBMStore();
|
|
1498
|
+
const [errors, setErrors] = useState4({});
|
|
1499
|
+
const [loading, setLoading] = useState4(false);
|
|
1500
|
+
const validate = () => {
|
|
1501
|
+
const e = {};
|
|
1502
|
+
if (!personalData.name.trim() || personalData.name.trim().split(" ").length < 2)
|
|
1503
|
+
e.name = "Informe o nome completo.";
|
|
1504
|
+
if (!/^\(\d{2}\) \d{5}-\d{4}$/.test(personalData.phone))
|
|
1505
|
+
e.phone = "Telefone inv\xE1lido.";
|
|
1506
|
+
if (!personalData.birthday) e.birthday = "Data de nascimento obrigat\xF3ria.";
|
|
1507
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(personalData.email))
|
|
1508
|
+
e.email = "E-mail inv\xE1lido.";
|
|
1509
|
+
setErrors(e);
|
|
1510
|
+
return Object.keys(e).length === 0;
|
|
1511
|
+
};
|
|
1512
|
+
const handleSubmit = async () => {
|
|
1513
|
+
if (!validate()) return;
|
|
1514
|
+
setLoading(true);
|
|
1515
|
+
try {
|
|
1516
|
+
const response = await SetPersonalDataForm({
|
|
1517
|
+
document: securityNumber,
|
|
1518
|
+
requestId: store.requestId,
|
|
1519
|
+
personalData
|
|
1520
|
+
});
|
|
1521
|
+
if (!response.success) {
|
|
1522
|
+
console.error("Failed to set personal data form:", response.message);
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
setStep(mappingFormStep["Address"]);
|
|
1526
|
+
onNext();
|
|
1527
|
+
} catch {
|
|
1528
|
+
console.error("An error occurred while setting personal data form.");
|
|
1529
|
+
} finally {
|
|
1530
|
+
setLoading(false);
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-4", children: [
|
|
1534
|
+
/* @__PURE__ */ jsxs13(FieldWrapper_default, { label: "CPF", children: [
|
|
1535
|
+
/* @__PURE__ */ jsx17(
|
|
1536
|
+
"input",
|
|
1537
|
+
{
|
|
1538
|
+
className: DisabledInputClass_default,
|
|
1539
|
+
value: formaters.cpf(securityNumber),
|
|
1540
|
+
disabled: true,
|
|
1541
|
+
readOnly: true
|
|
1542
|
+
}
|
|
1543
|
+
),
|
|
1544
|
+
/* @__PURE__ */ jsx17("p", { className: "text-xs text-gray-400 mt-1", children: /* @__PURE__ */ jsx17(
|
|
1545
|
+
"button",
|
|
1546
|
+
{
|
|
1547
|
+
type: "button",
|
|
1548
|
+
className: "text-(--pbm-primary) hover:text-(--pbm-primary)/60 cursor-pointer underline underline-offset-2 transition-colors",
|
|
1549
|
+
onClick: () => setModal({ id: "", open: false }),
|
|
1550
|
+
children: "Deseja alterar o CPF? Clique aqui."
|
|
1551
|
+
}
|
|
1552
|
+
) })
|
|
1553
|
+
] }),
|
|
1554
|
+
/* @__PURE__ */ jsx17(FieldWrapper_default, { label: "Nome completo", error: errors.name, children: /* @__PURE__ */ jsx17(
|
|
1555
|
+
"input",
|
|
1556
|
+
{
|
|
1557
|
+
className: InputClass_default(errors.name),
|
|
1558
|
+
placeholder: "Ex: Jo\xE3o da Silva",
|
|
1559
|
+
value: personalData.name,
|
|
1560
|
+
onChange: (e) => {
|
|
1561
|
+
setPersonalData({ name: e.target.value });
|
|
1562
|
+
setErrors((p) => ({ ...p, name: void 0 }));
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
) }),
|
|
1566
|
+
/* @__PURE__ */ jsxs13("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
1567
|
+
/* @__PURE__ */ jsx17(FieldWrapper_default, { label: "Telefone", error: errors.phone, children: /* @__PURE__ */ jsx17(
|
|
1568
|
+
"input",
|
|
1569
|
+
{
|
|
1570
|
+
className: InputClass_default(errors.phone),
|
|
1571
|
+
placeholder: "(11) 99999-8888",
|
|
1572
|
+
value: personalData.phone,
|
|
1573
|
+
onChange: (e) => {
|
|
1574
|
+
setPersonalData({ phone: formaters.phone(e.target.value) });
|
|
1575
|
+
setErrors((p) => ({ ...p, phone: void 0 }));
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
) }),
|
|
1579
|
+
/* @__PURE__ */ jsx17(FieldWrapper_default, { label: "Data de nascimento", error: errors.birthday, children: /* @__PURE__ */ jsx17(
|
|
1580
|
+
"input",
|
|
1581
|
+
{
|
|
1582
|
+
type: "date",
|
|
1583
|
+
className: InputClass_default(errors.birthday),
|
|
1584
|
+
value: personalData.birthday,
|
|
1585
|
+
onChange: (e) => {
|
|
1586
|
+
setPersonalData({ birthday: e.target.value });
|
|
1587
|
+
setErrors((p) => ({ ...p, birthday: void 0 }));
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
) })
|
|
1591
|
+
] }),
|
|
1592
|
+
/* @__PURE__ */ jsx17(FieldWrapper_default, { label: "E-mail", error: errors.email, children: /* @__PURE__ */ jsx17(
|
|
1593
|
+
"input",
|
|
1594
|
+
{
|
|
1595
|
+
type: "email",
|
|
1596
|
+
className: InputClass_default(errors.email),
|
|
1597
|
+
placeholder: "joao@email.com",
|
|
1598
|
+
value: personalData.email,
|
|
1599
|
+
onChange: (e) => {
|
|
1600
|
+
setPersonalData({ email: e.target.value });
|
|
1601
|
+
setErrors((p) => ({ ...p, email: void 0 }));
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
) }),
|
|
1605
|
+
/* @__PURE__ */ jsx17(StepActions_default, { onNext: handleSubmit, loading })
|
|
1606
|
+
] });
|
|
1607
|
+
};
|
|
1608
|
+
var StepPersonalDataForm_default = StepPersonalDataForm;
|
|
1609
|
+
|
|
1610
|
+
// src/components/Modals/CustomerNotRegistered/StepAddressForm.tsx
|
|
1611
|
+
import { useCallback as useCallback2, useState as useState5 } from "react";
|
|
1612
|
+
|
|
1613
|
+
// src/services/lookup-postal-code.ts
|
|
1614
|
+
import Cookies5 from "js-cookie";
|
|
1615
|
+
var LookupPostalCode = async ({ POSTAL_CODE }) => {
|
|
1616
|
+
const API_URL = getEnv("VITE_API_URL");
|
|
1617
|
+
const AUTH_TOKEN = Cookies5.get("pbm-token");
|
|
1618
|
+
if (!AUTH_TOKEN) {
|
|
1619
|
+
throw new Error("Token is not defined in cookies or is expired");
|
|
1620
|
+
}
|
|
1621
|
+
const response = await fetch(`${API_URL}/programregistration/consulta-cep/${POSTAL_CODE}`, {
|
|
1622
|
+
method: "GET",
|
|
1623
|
+
headers: {
|
|
1624
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
1625
|
+
"Content-Type": "application/json"
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
const dataResponse = await response.json();
|
|
1629
|
+
if (!dataResponse.success) {
|
|
1630
|
+
throw new Error(dataResponse.message || "Failed to fetch authorization");
|
|
1631
|
+
}
|
|
1632
|
+
return dataResponse;
|
|
1633
|
+
};
|
|
1634
|
+
|
|
1635
|
+
// src/services/set-address-data-form.ts
|
|
1636
|
+
import Cookies6 from "js-cookie";
|
|
1637
|
+
var SetAddressDataForm = async ({ document, requestId, address }) => {
|
|
1638
|
+
const API_URL = getEnv("VITE_API_URL");
|
|
1639
|
+
const AUTH_TOKEN = Cookies6.get("pbm-token");
|
|
1640
|
+
if (!AUTH_TOKEN) {
|
|
1641
|
+
throw new Error("Token is not defined in cookies or is expired");
|
|
1642
|
+
}
|
|
1643
|
+
const response = await fetch(`${API_URL}/programregistration/address`, {
|
|
1644
|
+
method: "PUT",
|
|
1645
|
+
headers: {
|
|
1646
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
1647
|
+
"Content-Type": "application/json"
|
|
1648
|
+
},
|
|
1649
|
+
body: JSON.stringify({ document, requestId, ...address })
|
|
1650
|
+
});
|
|
1651
|
+
const dataResponse = await response.json();
|
|
1652
|
+
if (!dataResponse.success) {
|
|
1653
|
+
throw new Error(dataResponse.message || "Failed to fetch authorization");
|
|
1654
|
+
}
|
|
1655
|
+
return dataResponse;
|
|
1656
|
+
};
|
|
1657
|
+
|
|
1658
|
+
// src/components/Modals/CustomerNotRegistered/StepAddressForm.tsx
|
|
1659
|
+
import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1660
|
+
var StepAddressForm = ({
|
|
1661
|
+
securityNumber,
|
|
1662
|
+
onNext,
|
|
1663
|
+
onBack
|
|
1664
|
+
}) => {
|
|
1665
|
+
const { address, setAddress, setStep } = usePBMForm();
|
|
1666
|
+
const store = usePBMStore();
|
|
1667
|
+
const [errors, setErrors] = useState5({});
|
|
1668
|
+
const [loadingCep, setLoadingCep] = useState5(false);
|
|
1669
|
+
const [loading, setLoading] = useState5(false);
|
|
1670
|
+
const fetchCEP = useCallback2(
|
|
1671
|
+
async (cep) => {
|
|
1672
|
+
const raw = cep.replace(/\D/g, "");
|
|
1673
|
+
if (raw.length !== 8) return;
|
|
1674
|
+
setLoadingCep(true);
|
|
1675
|
+
try {
|
|
1676
|
+
const response = await LookupPostalCode({ POSTAL_CODE: raw });
|
|
1677
|
+
if (!response.success) {
|
|
1678
|
+
console.error("Failed to lookup postal code");
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
setAddress({
|
|
1682
|
+
street: response.data.endereco,
|
|
1683
|
+
neighborhood: response.data.bairro,
|
|
1684
|
+
city: response.data.cidade,
|
|
1685
|
+
stateAddress: response.data.estado,
|
|
1686
|
+
postalcode: cep,
|
|
1687
|
+
complement: response.data.complementoSugeridoViaCep || ""
|
|
1688
|
+
});
|
|
1689
|
+
} catch {
|
|
1690
|
+
console.error("Failed to fetch address for CEP:", cep);
|
|
1691
|
+
} finally {
|
|
1692
|
+
setLoadingCep(false);
|
|
1693
|
+
}
|
|
1694
|
+
},
|
|
1695
|
+
[setAddress]
|
|
1696
|
+
);
|
|
1697
|
+
const validate = () => {
|
|
1698
|
+
const e = {};
|
|
1699
|
+
if (!/^\d{5}-\d{3}$/.test(address.postalcode))
|
|
1700
|
+
e.postalcode = "CEP inv\xE1lido.";
|
|
1701
|
+
if (!address.number.trim()) e.number = "N\xFAmero obrigat\xF3rio.";
|
|
1702
|
+
setErrors(e);
|
|
1703
|
+
return Object.keys(e).length === 0;
|
|
1704
|
+
};
|
|
1705
|
+
const handleSubmit = async () => {
|
|
1706
|
+
if (!validate()) return;
|
|
1707
|
+
setLoading(true);
|
|
1708
|
+
try {
|
|
1709
|
+
const response = await SetAddressDataForm({
|
|
1710
|
+
document: securityNumber,
|
|
1711
|
+
requestId: store.requestId,
|
|
1712
|
+
address: {
|
|
1713
|
+
postalcode: address.postalcode.replace(/\D/g, ""),
|
|
1714
|
+
number: address.number,
|
|
1715
|
+
complement: address.complement
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
if (!response.success) {
|
|
1719
|
+
console.log("Failed to set address data form:", response.message);
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
setStep(mappingFormStep["GenderResponsibility"]);
|
|
1723
|
+
onNext();
|
|
1724
|
+
} catch {
|
|
1725
|
+
console.log("An error occurred while submitting address form.");
|
|
1726
|
+
} finally {
|
|
1727
|
+
setLoading(false);
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
return /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-4", children: [
|
|
1731
|
+
/* @__PURE__ */ jsx18(FieldWrapper_default, { label: "CEP", error: errors.postalcode, children: /* @__PURE__ */ jsxs14("div", { className: "relative", children: [
|
|
1732
|
+
/* @__PURE__ */ jsx18(
|
|
1733
|
+
"input",
|
|
1734
|
+
{
|
|
1735
|
+
className: InputClass_default(errors.postalcode),
|
|
1736
|
+
placeholder: "00000-000",
|
|
1737
|
+
value: address.postalcode,
|
|
1738
|
+
onChange: (e) => {
|
|
1739
|
+
const formatted = formaters.cep(e.target.value);
|
|
1740
|
+
setAddress({ postalcode: formatted });
|
|
1741
|
+
setErrors((p) => ({
|
|
1742
|
+
...p,
|
|
1743
|
+
postalcode: void 0
|
|
1744
|
+
}));
|
|
1745
|
+
if (formatted.replace(/\D/g, "").length === 8)
|
|
1746
|
+
fetchCEP(formatted);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
),
|
|
1750
|
+
loadingCep && /* @__PURE__ */ jsx18("div", { className: "absolute right-3 top-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsxs14(
|
|
1751
|
+
"svg",
|
|
1752
|
+
{
|
|
1753
|
+
className: "h-4 w-4 animate-spin text-blue-500",
|
|
1754
|
+
viewBox: "0 0 24 24",
|
|
1755
|
+
fill: "none",
|
|
1756
|
+
children: [
|
|
1757
|
+
/* @__PURE__ */ jsx18(
|
|
1758
|
+
"circle",
|
|
1759
|
+
{
|
|
1760
|
+
className: "opacity-25",
|
|
1761
|
+
cx: "12",
|
|
1762
|
+
cy: "12",
|
|
1763
|
+
r: "10",
|
|
1764
|
+
stroke: "currentColor",
|
|
1765
|
+
strokeWidth: "4"
|
|
1766
|
+
}
|
|
1767
|
+
),
|
|
1768
|
+
/* @__PURE__ */ jsx18(
|
|
1769
|
+
"path",
|
|
1770
|
+
{
|
|
1771
|
+
className: "opacity-75",
|
|
1772
|
+
fill: "currentColor",
|
|
1773
|
+
d: "M4 12a8 8 0 018-8v8z"
|
|
1774
|
+
}
|
|
1775
|
+
)
|
|
1776
|
+
]
|
|
1777
|
+
}
|
|
1778
|
+
) })
|
|
1779
|
+
] }) }),
|
|
1780
|
+
/* @__PURE__ */ jsxs14("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
1781
|
+
/* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Rua", children: /* @__PURE__ */ jsx18(
|
|
1782
|
+
"input",
|
|
1783
|
+
{
|
|
1784
|
+
className: DisabledInputClass_default,
|
|
1785
|
+
value: address.street || "",
|
|
1786
|
+
disabled: true,
|
|
1787
|
+
readOnly: true,
|
|
1788
|
+
placeholder: "Preenchido pelo CEP"
|
|
1789
|
+
}
|
|
1790
|
+
) }),
|
|
1791
|
+
/* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Bairro", children: /* @__PURE__ */ jsx18(
|
|
1792
|
+
"input",
|
|
1793
|
+
{
|
|
1794
|
+
className: DisabledInputClass_default,
|
|
1795
|
+
value: address.neighborhood || "",
|
|
1796
|
+
disabled: true,
|
|
1797
|
+
readOnly: true,
|
|
1798
|
+
placeholder: "Preenchido pelo CEP"
|
|
1799
|
+
}
|
|
1800
|
+
) })
|
|
1801
|
+
] }),
|
|
1802
|
+
/* @__PURE__ */ jsxs14("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
1803
|
+
/* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Cidade", children: /* @__PURE__ */ jsx18(
|
|
1804
|
+
"input",
|
|
1805
|
+
{
|
|
1806
|
+
className: DisabledInputClass_default,
|
|
1807
|
+
value: address.city || "",
|
|
1808
|
+
disabled: true,
|
|
1809
|
+
readOnly: true,
|
|
1810
|
+
placeholder: "Preenchido pelo CEP"
|
|
1811
|
+
}
|
|
1812
|
+
) }),
|
|
1813
|
+
/* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Estado", children: /* @__PURE__ */ jsx18(
|
|
1814
|
+
"input",
|
|
1815
|
+
{
|
|
1816
|
+
className: DisabledInputClass_default,
|
|
1817
|
+
value: address.stateAddress || "",
|
|
1818
|
+
disabled: true,
|
|
1819
|
+
readOnly: true,
|
|
1820
|
+
placeholder: "UF"
|
|
1821
|
+
}
|
|
1822
|
+
) })
|
|
1823
|
+
] }),
|
|
1824
|
+
/* @__PURE__ */ jsxs14("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
1825
|
+
/* @__PURE__ */ jsx18(FieldWrapper_default, { label: "N\xFAmero", error: errors.number, children: /* @__PURE__ */ jsx18(
|
|
1826
|
+
"input",
|
|
1827
|
+
{
|
|
1828
|
+
className: InputClass_default(errors.number),
|
|
1829
|
+
placeholder: "Ex: 100",
|
|
1830
|
+
value: address.number,
|
|
1831
|
+
onChange: (e) => {
|
|
1832
|
+
setAddress({ number: e.target.value });
|
|
1833
|
+
setErrors((p) => ({ ...p, number: void 0 }));
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
) }),
|
|
1837
|
+
/* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Complemento", children: /* @__PURE__ */ jsx18(
|
|
1838
|
+
"input",
|
|
1839
|
+
{
|
|
1840
|
+
className: InputClass_default(),
|
|
1841
|
+
placeholder: "Apto, bloco...",
|
|
1842
|
+
value: address.complement,
|
|
1843
|
+
onChange: (e) => setAddress({ complement: e.target.value })
|
|
1844
|
+
}
|
|
1845
|
+
) })
|
|
1846
|
+
] }),
|
|
1847
|
+
/* @__PURE__ */ jsx18(StepActions_default, { onNext: handleSubmit, onBack, loading })
|
|
1848
|
+
] });
|
|
1849
|
+
};
|
|
1850
|
+
var StepAddressForm_default = StepAddressForm;
|
|
1851
|
+
|
|
1852
|
+
// src/components/Modals/CustomerNotRegistered/StepGenderForm.tsx
|
|
1853
|
+
import classNames10 from "classnames";
|
|
1854
|
+
import { useState as useState6 } from "react";
|
|
1855
|
+
|
|
1856
|
+
// src/services/set-gender-responsability-data-form.ts
|
|
1857
|
+
import Cookies7 from "js-cookie";
|
|
1858
|
+
var SetGenderResponsabilityDataForm = async ({ document, requestId, identity_responsibility }) => {
|
|
1859
|
+
const API_URL = getEnv("VITE_API_URL");
|
|
1860
|
+
const AUTH_TOKEN = Cookies7.get("pbm-token");
|
|
1861
|
+
if (!AUTH_TOKEN) {
|
|
1862
|
+
throw new Error("Token is not defined in cookies or is expired");
|
|
1863
|
+
}
|
|
1864
|
+
const response = await fetch(`${API_URL}/programregistration/genderResponsibility`, {
|
|
1865
|
+
method: "PUT",
|
|
1866
|
+
headers: {
|
|
1867
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
1868
|
+
"Content-Type": "application/json"
|
|
1869
|
+
},
|
|
1870
|
+
body: JSON.stringify({ document, requestId, ...identity_responsibility })
|
|
1871
|
+
});
|
|
1872
|
+
const dataResponse = await response.json();
|
|
1873
|
+
if (!dataResponse.success) {
|
|
1874
|
+
throw new Error(dataResponse.message || "Failed to fetch authorization");
|
|
1875
|
+
}
|
|
1876
|
+
return dataResponse;
|
|
1877
|
+
};
|
|
1878
|
+
|
|
1879
|
+
// src/components/Modals/CustomerNotRegistered/StepGenderForm.tsx
|
|
1880
|
+
import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1881
|
+
var StepGenderForm = ({
|
|
1882
|
+
securityNumber,
|
|
1883
|
+
onNext,
|
|
1884
|
+
onBack
|
|
1885
|
+
}) => {
|
|
1886
|
+
const { genderResponsibility, setGenderResponsibility, setStep } = usePBMForm();
|
|
1887
|
+
const store = usePBMStore();
|
|
1888
|
+
const [errors, setErrors] = useState6(
|
|
1889
|
+
{}
|
|
1890
|
+
);
|
|
1891
|
+
const [loading, setLoading] = useState6(false);
|
|
1892
|
+
const validate = () => {
|
|
1893
|
+
const e = {};
|
|
1894
|
+
if (!genderResponsibility.gender) e.gender = "Selecione o g\xEAnero.";
|
|
1895
|
+
if (genderResponsibility.patient === null)
|
|
1896
|
+
e.patient = "Informe se \xE9 o paciente.";
|
|
1897
|
+
setErrors(e);
|
|
1898
|
+
return Object.keys(e).length === 0;
|
|
1899
|
+
};
|
|
1900
|
+
const handleSubmit = async () => {
|
|
1901
|
+
if (!validate()) return;
|
|
1902
|
+
setLoading(true);
|
|
1903
|
+
try {
|
|
1904
|
+
const response = await SetGenderResponsabilityDataForm({
|
|
1905
|
+
document: securityNumber,
|
|
1906
|
+
requestId: store.requestId,
|
|
1907
|
+
identity_responsibility: {
|
|
1908
|
+
gender: genderResponsibility.gender,
|
|
1909
|
+
patient: genderResponsibility.patient
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
if (!response.success) {
|
|
1913
|
+
console.error(
|
|
1914
|
+
"Failed to submit gender responsibility data:",
|
|
1915
|
+
response.message
|
|
1916
|
+
);
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
setStep(mappingFormStep["Doctor"]);
|
|
1920
|
+
onNext();
|
|
1921
|
+
} catch {
|
|
1922
|
+
console.error(
|
|
1923
|
+
"An error occurred while submitting gender responsibility data."
|
|
1924
|
+
);
|
|
1925
|
+
} finally {
|
|
1926
|
+
setLoading(false);
|
|
755
1927
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
1928
|
+
};
|
|
1929
|
+
const genderOptions = [
|
|
1930
|
+
{ value: "M", label: "Masculino" },
|
|
1931
|
+
{ value: "F", label: "Feminino" },
|
|
1932
|
+
{ value: "O", label: "Outro" }
|
|
1933
|
+
];
|
|
1934
|
+
return /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-5", children: [
|
|
1935
|
+
/* @__PURE__ */ jsxs15("div", { children: [
|
|
1936
|
+
/* @__PURE__ */ jsx19("label", { className: "text-xs font-medium text-gray-500 uppercase tracking-wide block mb-2", children: "G\xEAnero" }),
|
|
1937
|
+
/* @__PURE__ */ jsx19("div", { className: "flex gap-2", children: genderOptions.map((opt) => /* @__PURE__ */ jsx19(
|
|
1938
|
+
"button",
|
|
1939
|
+
{
|
|
1940
|
+
type: "button",
|
|
1941
|
+
onClick: () => {
|
|
1942
|
+
setGenderResponsibility({ gender: opt.value });
|
|
1943
|
+
setErrors((p) => ({ ...p, gender: void 0 }));
|
|
1944
|
+
},
|
|
1945
|
+
className: classNames10(
|
|
1946
|
+
"flex-1 py-2.5 rounded-lg border text-sm font-medium transition-all",
|
|
1947
|
+
genderResponsibility.gender === opt.value ? "border-blue-500 bg-blue-500 text-white" : "border-gray-200 bg-gray-50 text-gray-600 hover:border-blue-300"
|
|
1948
|
+
),
|
|
1949
|
+
children: opt.label
|
|
1950
|
+
},
|
|
1951
|
+
opt.value
|
|
1952
|
+
)) }),
|
|
1953
|
+
errors.gender && /* @__PURE__ */ jsx19("span", { className: "text-xs text-red-500 mt-1 block", children: errors.gender })
|
|
1954
|
+
] }),
|
|
1955
|
+
/* @__PURE__ */ jsxs15("div", { children: [
|
|
1956
|
+
/* @__PURE__ */ jsx19("label", { className: "text-xs font-medium text-gray-500 uppercase tracking-wide block mb-2", children: "Voc\xEA \xE9 o paciente?" }),
|
|
1957
|
+
/* @__PURE__ */ jsx19("div", { className: "flex gap-2", children: [
|
|
1958
|
+
{ label: "Sim, sou o paciente", value: true },
|
|
1959
|
+
{ label: "N\xE3o, sou respons\xE1vel", value: false }
|
|
1960
|
+
].map((opt) => /* @__PURE__ */ jsx19(
|
|
1961
|
+
"button",
|
|
1962
|
+
{
|
|
1963
|
+
type: "button",
|
|
1964
|
+
onClick: () => {
|
|
1965
|
+
setGenderResponsibility({ patient: opt.value });
|
|
1966
|
+
setErrors((p) => ({ ...p, patient: void 0 }));
|
|
1967
|
+
},
|
|
1968
|
+
className: classNames10(
|
|
1969
|
+
"flex-1 py-2.5 rounded-lg border text-sm font-medium transition-all",
|
|
1970
|
+
genderResponsibility.patient === opt.value ? "border-blue-500 bg-blue-500 text-white" : "border-gray-200 bg-gray-50 text-gray-600 hover:border-blue-300"
|
|
1971
|
+
),
|
|
1972
|
+
children: opt.label
|
|
1973
|
+
},
|
|
1974
|
+
String(opt.value)
|
|
1975
|
+
)) }),
|
|
1976
|
+
errors.patient && /* @__PURE__ */ jsx19("span", { className: "text-xs text-red-500 mt-1 block", children: errors.patient })
|
|
1977
|
+
] }),
|
|
1978
|
+
/* @__PURE__ */ jsx19(StepActions_default, { onNext: handleSubmit, onBack, loading })
|
|
1979
|
+
] });
|
|
1980
|
+
};
|
|
1981
|
+
var StepGenderForm_default = StepGenderForm;
|
|
1982
|
+
|
|
1983
|
+
// src/components/Modals/CustomerNotRegistered/StepDoctorForm.tsx
|
|
1984
|
+
import { useCallback as useCallback3, useState as useState7 } from "react";
|
|
1985
|
+
|
|
1986
|
+
// src/utils/ufMapping.ts
|
|
1987
|
+
var BRAZILIAN_STATES = [
|
|
1988
|
+
"AC",
|
|
1989
|
+
"AL",
|
|
1990
|
+
"AP",
|
|
1991
|
+
"AM",
|
|
1992
|
+
"BA",
|
|
1993
|
+
"CE",
|
|
1994
|
+
"DF",
|
|
1995
|
+
"ES",
|
|
1996
|
+
"GO",
|
|
1997
|
+
"MA",
|
|
1998
|
+
"MT",
|
|
1999
|
+
"MS",
|
|
2000
|
+
"MG",
|
|
2001
|
+
"PA",
|
|
2002
|
+
"PB",
|
|
2003
|
+
"PR",
|
|
2004
|
+
"PE",
|
|
2005
|
+
"PI",
|
|
2006
|
+
"RJ",
|
|
2007
|
+
"RN",
|
|
2008
|
+
"RS",
|
|
2009
|
+
"RO",
|
|
2010
|
+
"RR",
|
|
2011
|
+
"SC",
|
|
2012
|
+
"SP",
|
|
2013
|
+
"SE",
|
|
2014
|
+
"TO"
|
|
2015
|
+
];
|
|
2016
|
+
|
|
2017
|
+
// src/services/set-doctor-data-form.ts
|
|
2018
|
+
import Cookies8 from "js-cookie";
|
|
2019
|
+
var SetDoctorDataForm = async ({ document, requestId, doctor }) => {
|
|
2020
|
+
const API_URL = getEnv("VITE_API_URL");
|
|
2021
|
+
const AUTH_TOKEN = Cookies8.get("pbm-token");
|
|
2022
|
+
if (!AUTH_TOKEN) {
|
|
2023
|
+
throw new Error("Token is not defined in cookies or is expired");
|
|
2024
|
+
}
|
|
2025
|
+
const response = await fetch(`${API_URL}/programregistration/doctorName`, {
|
|
2026
|
+
method: "PUT",
|
|
2027
|
+
headers: {
|
|
2028
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
2029
|
+
"Content-Type": "application/json"
|
|
2030
|
+
},
|
|
2031
|
+
body: JSON.stringify({ document, requestId, ...doctor })
|
|
2032
|
+
});
|
|
2033
|
+
const dataResponse = await response.json();
|
|
2034
|
+
if (!dataResponse.success) {
|
|
2035
|
+
throw new Error(dataResponse.message || "Failed to fetch authorization");
|
|
2036
|
+
}
|
|
2037
|
+
return dataResponse;
|
|
2038
|
+
};
|
|
2039
|
+
|
|
2040
|
+
// src/services/lookup-doctor.ts
|
|
2041
|
+
import Cookies9 from "js-cookie";
|
|
2042
|
+
var LookupDoctor = async ({ typeCredential, register, uf }) => {
|
|
2043
|
+
const API_URL = getEnv("VITE_API_URL");
|
|
2044
|
+
const AUTH_TOKEN = Cookies9.get("pbm-token");
|
|
2045
|
+
if (!AUTH_TOKEN) {
|
|
2046
|
+
throw new Error("Token is not defined in cookies or is expired");
|
|
2047
|
+
}
|
|
2048
|
+
const queryParams = new URLSearchParams({
|
|
2049
|
+
tipoCredencial: typeCredential,
|
|
2050
|
+
registro: register,
|
|
2051
|
+
uf
|
|
2052
|
+
});
|
|
2053
|
+
const response = await fetch(`${API_URL}/doctors/consulta-profissional?${queryParams.toString()}`, {
|
|
2054
|
+
method: "GET",
|
|
2055
|
+
headers: {
|
|
2056
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
2057
|
+
"Content-Type": "application/json"
|
|
759
2058
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
2059
|
+
});
|
|
2060
|
+
const dataResponse = await response.json();
|
|
2061
|
+
if (!dataResponse.success) {
|
|
2062
|
+
throw new Error(dataResponse.message || "Failed to fetch authorization");
|
|
2063
|
+
}
|
|
2064
|
+
return dataResponse;
|
|
2065
|
+
};
|
|
2066
|
+
|
|
2067
|
+
// src/components/Modals/CustomerNotRegistered/StepDoctorForm.tsx
|
|
2068
|
+
import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2069
|
+
var StepDoctorForm = ({
|
|
2070
|
+
securityNumber,
|
|
2071
|
+
onNext,
|
|
2072
|
+
onBack
|
|
2073
|
+
}) => {
|
|
2074
|
+
const { doctor, setDoctor, setStep } = usePBMForm();
|
|
2075
|
+
const store = usePBMStore();
|
|
2076
|
+
const [errors, setErrors] = useState7({});
|
|
2077
|
+
const [loadingDoctor, setLoadingDoctor] = useState7(false);
|
|
2078
|
+
const [loading, setLoading] = useState7(false);
|
|
2079
|
+
const fetchDoctor = useCallback3(async () => {
|
|
2080
|
+
if (!doctor.register || !doctor.state || !doctor.typeCredential) return;
|
|
2081
|
+
setLoadingDoctor(true);
|
|
2082
|
+
try {
|
|
2083
|
+
const response = await LookupDoctor({
|
|
2084
|
+
typeCredential: doctor.typeCredential,
|
|
2085
|
+
register: doctor.register,
|
|
2086
|
+
uf: doctor.state
|
|
2087
|
+
});
|
|
2088
|
+
if (!response.success) {
|
|
2089
|
+
console.error("Failed to fetch doctor data:", response.message);
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
const data = response.data;
|
|
2093
|
+
if (data?.nomeProfissional) {
|
|
2094
|
+
setDoctor({ doctorName: data.nomeProfissional });
|
|
2095
|
+
}
|
|
2096
|
+
} catch {
|
|
2097
|
+
console.error("An error occurred while fetching doctor data.");
|
|
2098
|
+
} finally {
|
|
2099
|
+
setLoadingDoctor(false);
|
|
763
2100
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
2101
|
+
}, [doctor.register, doctor.state, doctor.typeCredential, setDoctor]);
|
|
2102
|
+
const validate = () => {
|
|
2103
|
+
const e = {};
|
|
2104
|
+
if (!doctor.typeCredential)
|
|
2105
|
+
e.typeCredential = "Tipo de credencial obrigat\xF3rio.";
|
|
2106
|
+
if (!doctor.register.trim()) e.register = "N\xFAmero do registro obrigat\xF3rio.";
|
|
2107
|
+
if (!doctor.state) e.state = "Estado obrigat\xF3rio.";
|
|
2108
|
+
if (!doctor.doctorName.trim()) e.doctorName = "Nome do m\xE9dico obrigat\xF3rio.";
|
|
2109
|
+
setErrors(e);
|
|
2110
|
+
return Object.keys(e).length === 0;
|
|
2111
|
+
};
|
|
2112
|
+
const handleSubmit = async () => {
|
|
2113
|
+
if (!validate()) return;
|
|
2114
|
+
setLoading(true);
|
|
2115
|
+
try {
|
|
2116
|
+
const response = await SetDoctorDataForm({
|
|
2117
|
+
document: securityNumber,
|
|
2118
|
+
requestId: store.requestId,
|
|
2119
|
+
doctor: {
|
|
2120
|
+
typeCredential: doctor.typeCredential,
|
|
2121
|
+
register: doctor.register,
|
|
2122
|
+
state: doctor.state,
|
|
2123
|
+
doctorName: doctor.doctorName
|
|
778
2124
|
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
console.error(
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
const fetchDiscountWithDocument = async () => {
|
|
785
|
-
if (!securityNumber) {
|
|
786
|
-
console.error("PBMLOG: Document is not defined");
|
|
2125
|
+
});
|
|
2126
|
+
if (!response.success) {
|
|
2127
|
+
console.error("Failed to submit doctor data:", response.message);
|
|
787
2128
|
return;
|
|
788
2129
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
2130
|
+
setStep(mappingFormStep["Acceptances"]);
|
|
2131
|
+
onNext();
|
|
2132
|
+
} catch {
|
|
2133
|
+
console.error("An error occurred while submitting doctor data.");
|
|
2134
|
+
} finally {
|
|
2135
|
+
setLoading(false);
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-4", children: [
|
|
2139
|
+
/* @__PURE__ */ jsxs16("div", { className: "grid grid-cols-3 gap-3", children: [
|
|
2140
|
+
/* @__PURE__ */ jsx20(FieldWrapper_default, { label: "Tipo credencial", error: errors.typeCredential, children: /* @__PURE__ */ jsxs16(
|
|
2141
|
+
"select",
|
|
2142
|
+
{
|
|
2143
|
+
className: InputClass_default(errors.typeCredential),
|
|
2144
|
+
value: doctor.typeCredential,
|
|
2145
|
+
onChange: (e) => {
|
|
2146
|
+
setDoctor({ typeCredential: e.target.value });
|
|
2147
|
+
setErrors((p) => ({
|
|
2148
|
+
...p,
|
|
2149
|
+
typeCredential: void 0
|
|
2150
|
+
}));
|
|
2151
|
+
},
|
|
2152
|
+
children: [
|
|
2153
|
+
/* @__PURE__ */ jsx20("option", { value: "CRM", children: "CRM" }),
|
|
2154
|
+
/* @__PURE__ */ jsx20("option", { value: "CRO", children: "CRO" }),
|
|
2155
|
+
/* @__PURE__ */ jsx20("option", { value: "CRF", children: "CRF" })
|
|
2156
|
+
]
|
|
802
2157
|
}
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
2158
|
+
) }),
|
|
2159
|
+
/* @__PURE__ */ jsx20(FieldWrapper_default, { label: "Estado (UF)", error: errors.state, children: /* @__PURE__ */ jsxs16(
|
|
2160
|
+
"select",
|
|
2161
|
+
{
|
|
2162
|
+
className: InputClass_default(errors.state),
|
|
2163
|
+
value: doctor.state,
|
|
2164
|
+
onChange: (e) => {
|
|
2165
|
+
setDoctor({ state: e.target.value });
|
|
2166
|
+
setErrors((p) => ({ ...p, state: void 0 }));
|
|
2167
|
+
},
|
|
2168
|
+
children: [
|
|
2169
|
+
/* @__PURE__ */ jsx20("option", { value: "", children: "UF" }),
|
|
2170
|
+
BRAZILIAN_STATES.map((state) => /* @__PURE__ */ jsx20("option", { value: state, children: state }, state))
|
|
2171
|
+
]
|
|
2172
|
+
}
|
|
2173
|
+
) }),
|
|
2174
|
+
/* @__PURE__ */ jsx20(FieldWrapper_default, { label: "N\xBA registro", error: errors.register, children: /* @__PURE__ */ jsx20("div", { className: "relative", children: /* @__PURE__ */ jsx20(
|
|
2175
|
+
"input",
|
|
2176
|
+
{
|
|
2177
|
+
className: InputClass_default(errors.register),
|
|
2178
|
+
placeholder: "Ex: 123456",
|
|
2179
|
+
value: doctor.register,
|
|
2180
|
+
onChange: (e) => {
|
|
2181
|
+
setDoctor({ register: e.target.value.replace(/\D/g, "") });
|
|
2182
|
+
setErrors((p) => ({
|
|
2183
|
+
...p,
|
|
2184
|
+
register: void 0
|
|
2185
|
+
}));
|
|
2186
|
+
},
|
|
2187
|
+
onBlur: fetchDoctor
|
|
2188
|
+
}
|
|
2189
|
+
) }) })
|
|
2190
|
+
] }),
|
|
2191
|
+
/* @__PURE__ */ jsxs16(FieldWrapper_default, { label: "Nome do m\xE9dico", error: errors.doctorName, children: [
|
|
2192
|
+
/* @__PURE__ */ jsxs16("div", { className: "relative", children: [
|
|
2193
|
+
/* @__PURE__ */ jsx20(
|
|
2194
|
+
"input",
|
|
827
2195
|
{
|
|
828
|
-
className:
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
data: item,
|
|
839
|
-
checked: selectedDiscout === ID_INPUT,
|
|
840
|
-
onChange: () => setSelectedDiscount(ID_INPUT)
|
|
841
|
-
},
|
|
842
|
-
index
|
|
843
|
-
);
|
|
844
|
-
})
|
|
845
|
-
]
|
|
2196
|
+
className: InputClass_default(errors.doctorName),
|
|
2197
|
+
placeholder: loadingDoctor ? "Buscando m\xE9dico..." : "Dr. Nome Completo",
|
|
2198
|
+
value: doctor.doctorName,
|
|
2199
|
+
onChange: (e) => {
|
|
2200
|
+
setDoctor({ doctorName: e.target.value });
|
|
2201
|
+
setErrors((p) => ({
|
|
2202
|
+
...p,
|
|
2203
|
+
doctorName: void 0
|
|
2204
|
+
}));
|
|
2205
|
+
}
|
|
846
2206
|
}
|
|
847
2207
|
),
|
|
848
|
-
|
|
849
|
-
|
|
2208
|
+
loadingDoctor && /* @__PURE__ */ jsx20("div", { className: "absolute right-3 top-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsxs16(
|
|
2209
|
+
"svg",
|
|
850
2210
|
{
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
2211
|
+
className: "h-4 w-4 animate-spin text-blue-500",
|
|
2212
|
+
viewBox: "0 0 24 24",
|
|
2213
|
+
fill: "none",
|
|
854
2214
|
children: [
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
2215
|
+
/* @__PURE__ */ jsx20(
|
|
2216
|
+
"circle",
|
|
2217
|
+
{
|
|
2218
|
+
className: "opacity-25",
|
|
2219
|
+
cx: "12",
|
|
2220
|
+
cy: "12",
|
|
2221
|
+
r: "10",
|
|
2222
|
+
stroke: "currentColor",
|
|
2223
|
+
strokeWidth: "4"
|
|
2224
|
+
}
|
|
2225
|
+
),
|
|
2226
|
+
/* @__PURE__ */ jsx20(
|
|
2227
|
+
"path",
|
|
2228
|
+
{
|
|
2229
|
+
className: "opacity-75",
|
|
2230
|
+
fill: "currentColor",
|
|
2231
|
+
d: "M4 12a8 8 0 018-8v8z"
|
|
2232
|
+
}
|
|
2233
|
+
)
|
|
858
2234
|
]
|
|
859
2235
|
}
|
|
860
|
-
)
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
2236
|
+
) })
|
|
2237
|
+
] }),
|
|
2238
|
+
/* @__PURE__ */ jsx20("p", { className: "text-xs text-gray-400 mt-0.5", children: "Preenchido automaticamente ao informar registro + UF." })
|
|
2239
|
+
] }),
|
|
2240
|
+
/* @__PURE__ */ jsx20(StepActions_default, { onNext: handleSubmit, onBack, loading })
|
|
2241
|
+
] });
|
|
2242
|
+
};
|
|
2243
|
+
var StepDoctorForm_default = StepDoctorForm;
|
|
2244
|
+
|
|
2245
|
+
// src/components/Modals/CustomerNotRegistered/StepAcceptancesForm.tsx
|
|
2246
|
+
import { useState as useState8 } from "react";
|
|
2247
|
+
|
|
2248
|
+
// src/components/Modals/CustomerNotRegistered/Shared/CheckRow.tsx
|
|
2249
|
+
import classNames11 from "classnames";
|
|
2250
|
+
import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2251
|
+
var CheckRow = ({
|
|
2252
|
+
label,
|
|
2253
|
+
checked,
|
|
2254
|
+
onChange,
|
|
2255
|
+
required,
|
|
2256
|
+
error
|
|
2257
|
+
}) => /* @__PURE__ */ jsxs17(
|
|
2258
|
+
"label",
|
|
2259
|
+
{
|
|
2260
|
+
className: classNames11(
|
|
2261
|
+
"flex items-start gap-3 cursor-pointer group p-3 rounded-lg border transition-all",
|
|
2262
|
+
checked ? "border-emerald-200 bg-emerald-50/60" : "border-zinc-100 hover:border-zinc-200 bg-zinc-50/40",
|
|
2263
|
+
error ? "border-red-300 bg-red-50/40" : ""
|
|
2264
|
+
),
|
|
2265
|
+
children: [
|
|
2266
|
+
/* @__PURE__ */ jsx21(
|
|
2267
|
+
"div",
|
|
2268
|
+
{
|
|
2269
|
+
className: classNames11(
|
|
2270
|
+
"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border transition-all",
|
|
2271
|
+
checked ? "border-(--pbm-primary) bg-(--pbm-primary)" : "border-zinc-300 bg-white"
|
|
2272
|
+
),
|
|
2273
|
+
children: checked && /* @__PURE__ */ jsx21("svg", { className: "h-2.5 w-2.5 text-white", viewBox: "0 0 10 8", fill: "none", children: /* @__PURE__ */ jsx21(
|
|
2274
|
+
"path",
|
|
864
2275
|
{
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
2276
|
+
d: "M1 4l3 3 5-6",
|
|
2277
|
+
stroke: "currentColor",
|
|
2278
|
+
strokeWidth: "1.8",
|
|
2279
|
+
strokeLinecap: "round",
|
|
2280
|
+
strokeLinejoin: "round"
|
|
870
2281
|
}
|
|
2282
|
+
) })
|
|
2283
|
+
}
|
|
2284
|
+
),
|
|
2285
|
+
/* @__PURE__ */ jsxs17("span", { className: "text-sm text-zinc-700 leading-snug", children: [
|
|
2286
|
+
label,
|
|
2287
|
+
required && /* @__PURE__ */ jsx21("span", { className: "text-red-400 ml-1", children: "*" })
|
|
2288
|
+
] }),
|
|
2289
|
+
/* @__PURE__ */ jsx21(
|
|
2290
|
+
"input",
|
|
2291
|
+
{
|
|
2292
|
+
type: "checkbox",
|
|
2293
|
+
className: "sr-only",
|
|
2294
|
+
checked,
|
|
2295
|
+
onChange: (e) => onChange(e.target.checked)
|
|
2296
|
+
}
|
|
2297
|
+
)
|
|
2298
|
+
]
|
|
2299
|
+
}
|
|
2300
|
+
);
|
|
2301
|
+
var CheckRow_default = CheckRow;
|
|
2302
|
+
|
|
2303
|
+
// src/services/set-acceptances-data-form.ts
|
|
2304
|
+
import Cookies10 from "js-cookie";
|
|
2305
|
+
var SetAcceptancesDataForm = async ({ document, requestId, lgpd }) => {
|
|
2306
|
+
const API_URL = getEnv("VITE_API_URL");
|
|
2307
|
+
const AUTH_TOKEN = Cookies10.get("pbm-token");
|
|
2308
|
+
if (!AUTH_TOKEN) {
|
|
2309
|
+
throw new Error("Token is not defined in cookies or is expired");
|
|
2310
|
+
}
|
|
2311
|
+
const response = await fetch(`${API_URL}/programregistration/acceptances`, {
|
|
2312
|
+
method: "PUT",
|
|
2313
|
+
headers: {
|
|
2314
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
2315
|
+
"Content-Type": "application/json"
|
|
2316
|
+
},
|
|
2317
|
+
body: JSON.stringify({ document, requestId, ...lgpd })
|
|
2318
|
+
});
|
|
2319
|
+
const dataResponse = await response.json();
|
|
2320
|
+
if (!dataResponse.success) {
|
|
2321
|
+
throw new Error(dataResponse.message || "Failed to fetch authorization");
|
|
2322
|
+
}
|
|
2323
|
+
return dataResponse;
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
// src/components/Modals/CustomerNotRegistered/StepAcceptancesForm.tsx
|
|
2327
|
+
import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2328
|
+
var StepAcceptancesForm = ({
|
|
2329
|
+
securityNumber,
|
|
2330
|
+
onBack,
|
|
2331
|
+
onDone
|
|
2332
|
+
}) => {
|
|
2333
|
+
const { acceptances, setAcceptances } = usePBMForm();
|
|
2334
|
+
const store = usePBMStore();
|
|
2335
|
+
const [errors, setErrors] = useState8({});
|
|
2336
|
+
const [loading, setLoading] = useState8(false);
|
|
2337
|
+
const validate = () => {
|
|
2338
|
+
const e = {};
|
|
2339
|
+
if (!acceptances.acceptsPrivacyTermsLGPD)
|
|
2340
|
+
e.lgpd = "\xC9 obrigat\xF3rio aceitar os termos de privacidade (LGPD).";
|
|
2341
|
+
setErrors(e);
|
|
2342
|
+
return Object.keys(e).length === 0;
|
|
2343
|
+
};
|
|
2344
|
+
const handleSubmit = async () => {
|
|
2345
|
+
if (!validate()) return;
|
|
2346
|
+
setLoading(true);
|
|
2347
|
+
try {
|
|
2348
|
+
const response = await SetAcceptancesDataForm({
|
|
2349
|
+
document: securityNumber,
|
|
2350
|
+
requestId: store.requestId,
|
|
2351
|
+
lgpd: {
|
|
2352
|
+
acceptPhone: acceptances.acceptPhone,
|
|
2353
|
+
acceptsSms: acceptances.acceptsSms,
|
|
2354
|
+
acceptsEmail: acceptances.acceptsEmail,
|
|
2355
|
+
acceptsMail: acceptances.acceptsMail,
|
|
2356
|
+
acceptsPrivacyTermsLGPD: acceptances.acceptsPrivacyTermsLGPD
|
|
2357
|
+
}
|
|
2358
|
+
});
|
|
2359
|
+
if (!response.success) {
|
|
2360
|
+
console.error("Failed to submit acceptances data:", response.message);
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
onDone();
|
|
2364
|
+
} catch {
|
|
2365
|
+
console.error("An error occurred while submitting acceptances data.");
|
|
2366
|
+
} finally {
|
|
2367
|
+
setLoading(false);
|
|
2368
|
+
}
|
|
2369
|
+
};
|
|
2370
|
+
return /* @__PURE__ */ jsxs18("div", { className: "flex flex-col gap-3", children: [
|
|
2371
|
+
/* @__PURE__ */ jsx22("p", { className: "text-xs text-gray-500 mb-1", children: "Selecione como deseja receber comunica\xE7\xF5es:" }),
|
|
2372
|
+
/* @__PURE__ */ jsx22(
|
|
2373
|
+
CheckRow_default,
|
|
2374
|
+
{
|
|
2375
|
+
label: "Aceito receber contato por telefone",
|
|
2376
|
+
checked: acceptances.acceptPhone,
|
|
2377
|
+
onChange: (v) => setAcceptances({ acceptPhone: v })
|
|
2378
|
+
}
|
|
2379
|
+
),
|
|
2380
|
+
/* @__PURE__ */ jsx22(
|
|
2381
|
+
CheckRow_default,
|
|
2382
|
+
{
|
|
2383
|
+
label: "Aceito receber SMS",
|
|
2384
|
+
checked: acceptances.acceptsSms,
|
|
2385
|
+
onChange: (v) => setAcceptances({ acceptsSms: v })
|
|
2386
|
+
}
|
|
2387
|
+
),
|
|
2388
|
+
/* @__PURE__ */ jsx22(
|
|
2389
|
+
CheckRow_default,
|
|
2390
|
+
{
|
|
2391
|
+
label: "Aceito receber e-mails",
|
|
2392
|
+
checked: acceptances.acceptsEmail,
|
|
2393
|
+
onChange: (v) => setAcceptances({ acceptsEmail: v })
|
|
2394
|
+
}
|
|
2395
|
+
),
|
|
2396
|
+
/* @__PURE__ */ jsx22(
|
|
2397
|
+
CheckRow_default,
|
|
2398
|
+
{
|
|
2399
|
+
label: "Aceito receber correspond\xEAncias por correio",
|
|
2400
|
+
checked: acceptances.acceptsMail,
|
|
2401
|
+
onChange: (v) => setAcceptances({ acceptsMail: v })
|
|
2402
|
+
}
|
|
2403
|
+
),
|
|
2404
|
+
/* @__PURE__ */ jsxs18("div", { className: "mt-1", children: [
|
|
2405
|
+
/* @__PURE__ */ jsx22(
|
|
2406
|
+
CheckRow_default,
|
|
2407
|
+
{
|
|
2408
|
+
label: "Li e aceito os Termos de Privacidade (LGPD)",
|
|
2409
|
+
checked: acceptances.acceptsPrivacyTermsLGPD,
|
|
2410
|
+
onChange: (v) => {
|
|
2411
|
+
setAcceptances({ acceptsPrivacyTermsLGPD: v });
|
|
2412
|
+
setErrors({});
|
|
2413
|
+
},
|
|
2414
|
+
required: true,
|
|
2415
|
+
error: errors.lgpd
|
|
2416
|
+
}
|
|
2417
|
+
),
|
|
2418
|
+
errors.lgpd && /* @__PURE__ */ jsx22("span", { className: "text-xs text-red-500 mt-1 block pl-1", children: errors.lgpd })
|
|
2419
|
+
] }),
|
|
2420
|
+
/* @__PURE__ */ jsx22(
|
|
2421
|
+
StepActions_default,
|
|
2422
|
+
{
|
|
2423
|
+
onNext: handleSubmit,
|
|
2424
|
+
onBack,
|
|
2425
|
+
loading,
|
|
2426
|
+
nextLabel: "Concluir cadastro",
|
|
2427
|
+
isLast: true
|
|
2428
|
+
}
|
|
2429
|
+
)
|
|
2430
|
+
] });
|
|
2431
|
+
};
|
|
2432
|
+
var StepAcceptancesForm_default = StepAcceptancesForm;
|
|
2433
|
+
|
|
2434
|
+
// src/components/Modals/CustomerNotRegistered/Shared/StepProgress.tsx
|
|
2435
|
+
import classNames12 from "classnames";
|
|
2436
|
+
import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2437
|
+
var STEP_LABELS = [
|
|
2438
|
+
"Dados Pessoais",
|
|
2439
|
+
"Endere\xE7o",
|
|
2440
|
+
"Perfil",
|
|
2441
|
+
"M\xE9dico",
|
|
2442
|
+
"Aceites"
|
|
2443
|
+
];
|
|
2444
|
+
var StepProgress = ({ current }) => /* @__PURE__ */ jsx23("div", { className: "flex items-center gap-1 mb-6", children: STEP_LABELS.map((label, i) => {
|
|
2445
|
+
const done = i < current;
|
|
2446
|
+
const active = i === current;
|
|
2447
|
+
return /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-1 flex-1 min-w-0", children: [
|
|
2448
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex flex-col items-center gap-1 shrink-0", children: [
|
|
2449
|
+
/* @__PURE__ */ jsx23(
|
|
2450
|
+
"div",
|
|
2451
|
+
{
|
|
2452
|
+
className: classNames12(
|
|
2453
|
+
"flex h-7 w-7 items-center justify-center rounded-full text-xs font-semibold transition-all",
|
|
2454
|
+
done ? "bg-emerald-600 text-white" : active ? "bg-(--pbm-primary) text-white ring-4 ring-(--pbm-primary)/15" : "bg-zinc-100 text-zinc-400"
|
|
871
2455
|
),
|
|
872
|
-
/* @__PURE__ */
|
|
873
|
-
|
|
2456
|
+
children: done ? /* @__PURE__ */ jsx23("svg", { className: "h-3.5 w-3.5", viewBox: "0 0 12 10", fill: "none", children: /* @__PURE__ */ jsx23(
|
|
2457
|
+
"path",
|
|
874
2458
|
{
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
2459
|
+
d: "M1 5l4 4 6-8",
|
|
2460
|
+
stroke: "currentColor",
|
|
2461
|
+
strokeWidth: "2",
|
|
2462
|
+
strokeLinecap: "round",
|
|
2463
|
+
strokeLinejoin: "round"
|
|
879
2464
|
}
|
|
880
|
-
)
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
2465
|
+
) }) : i + 1
|
|
2466
|
+
}
|
|
2467
|
+
),
|
|
2468
|
+
/* @__PURE__ */ jsx23(
|
|
2469
|
+
"span",
|
|
2470
|
+
{
|
|
2471
|
+
className: classNames12(
|
|
2472
|
+
"text-[10px] font-medium whitespace-nowrap hidden sm:block",
|
|
2473
|
+
active ? "text-(--pbm-primary)" : done ? "text-emerald-600" : "text-zinc-400"
|
|
2474
|
+
),
|
|
2475
|
+
children: label
|
|
2476
|
+
}
|
|
2477
|
+
)
|
|
2478
|
+
] }),
|
|
2479
|
+
i < STEP_LABELS.length - 1 && /* @__PURE__ */ jsx23(
|
|
2480
|
+
"div",
|
|
2481
|
+
{
|
|
2482
|
+
className: classNames12(
|
|
2483
|
+
"h-0.5 flex-1 rounded transition-all mx-1 mb-4",
|
|
2484
|
+
done ? "bg-(--pbm-primary)" : "bg-zinc-200"
|
|
2485
|
+
)
|
|
2486
|
+
}
|
|
2487
|
+
)
|
|
2488
|
+
] }, i);
|
|
2489
|
+
}) });
|
|
2490
|
+
var StepProgress_default = StepProgress;
|
|
887
2491
|
|
|
888
|
-
// src/components/
|
|
889
|
-
import { jsx as
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
const handleOpenModal = () => {
|
|
894
|
-
if (!urlAcceptTerms) return;
|
|
895
|
-
setModal({ open: true, id: "iframe_pbm", label: "Aceitar os termos", url: urlAcceptTerms });
|
|
896
|
-
};
|
|
897
|
-
return /* @__PURE__ */ jsxs8(
|
|
898
|
-
"section",
|
|
2492
|
+
// src/components/Modals/CustomerNotRegistered/Shared/SuccessScreen.tsx
|
|
2493
|
+
import { jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2494
|
+
var SuccessScreen = ({ onClose }) => /* @__PURE__ */ jsxs20("div", { className: "flex flex-col items-center gap-4 py-4 text-center", children: [
|
|
2495
|
+
/* @__PURE__ */ jsx24("div", { className: "flex h-16 w-16 items-center justify-center rounded-full bg-green-100", children: /* @__PURE__ */ jsx24("svg", { className: "h-8 w-8 text-green-500", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx24(
|
|
2496
|
+
"path",
|
|
899
2497
|
{
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
/* @__PURE__ */ jsx12(Title_default, { className: "w-full", textColor, children: "CPF n\xE3o cadastrado." }),
|
|
906
|
-
/* @__PURE__ */ jsxs8(Text_default, { className: "w-full", textColor, children: [
|
|
907
|
-
"Conclua seu cadastro para habilitar o benef\xEDcio. ",
|
|
908
|
-
/* @__PURE__ */ jsx12("br", {}),
|
|
909
|
-
"Ao clicar em \u201CAceitar os termos\u201D, voc\xEA ir\xE1 para uma p\xE1gina externa. Aceite os termos e volte para continuar."
|
|
910
|
-
] }),
|
|
911
|
-
/* @__PURE__ */ jsx12(Button_default, { onClick: () => handleOpenModal(), style: { backgroundColor: "var(--pbm-primary)" }, children: "Aceitar os termos" })
|
|
912
|
-
]
|
|
2498
|
+
d: "M5 13l4 4L19 7",
|
|
2499
|
+
stroke: "currentColor",
|
|
2500
|
+
strokeWidth: "2.5",
|
|
2501
|
+
strokeLinecap: "round",
|
|
2502
|
+
strokeLinejoin: "round"
|
|
913
2503
|
}
|
|
914
|
-
)
|
|
915
|
-
|
|
916
|
-
|
|
2504
|
+
) }) }),
|
|
2505
|
+
/* @__PURE__ */ jsxs20("div", { children: [
|
|
2506
|
+
/* @__PURE__ */ jsx24("h3", { className: "text-base font-semibold text-gray-800", children: "Cadastro conclu\xEDdo!" }),
|
|
2507
|
+
/* @__PURE__ */ jsx24("p", { className: "text-sm text-zinc-500 mt-1", children: "Voc\xEA j\xE1 pode aproveitar os benef\xEDcios de farm\xE1cia." })
|
|
2508
|
+
] }),
|
|
2509
|
+
/* @__PURE__ */ jsx24(
|
|
2510
|
+
"button",
|
|
2511
|
+
{
|
|
2512
|
+
onClick: onClose,
|
|
2513
|
+
className: "cursor-pointer mt-2 rounded-lg bg-(--primary-color) px-6 py-2.5 text-sm font-semibold text-white hover:bg-(--primary-color)/80 transition-all",
|
|
2514
|
+
children: "Fechar"
|
|
2515
|
+
}
|
|
2516
|
+
)
|
|
2517
|
+
] });
|
|
2518
|
+
var SuccessScreen_default = SuccessScreen;
|
|
917
2519
|
|
|
918
|
-
// src/components/
|
|
919
|
-
import { jsx as
|
|
920
|
-
|
|
921
|
-
const {
|
|
922
|
-
const {
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
2520
|
+
// src/components/Modals/CustomerNotRegistered/index.tsx
|
|
2521
|
+
import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2522
|
+
var CustomerNotRegistered = ({ ID }) => {
|
|
2523
|
+
const { modal, setModal } = useModal();
|
|
2524
|
+
const { securityNumber } = usePBMStore();
|
|
2525
|
+
const { resetForm, step, setStep } = usePBMForm();
|
|
2526
|
+
const [done, setDone] = useState9(false);
|
|
2527
|
+
const closeModal = () => {
|
|
2528
|
+
setModal({ id: "", open: false });
|
|
2529
|
+
setTimeout(() => {
|
|
2530
|
+
setStep(0);
|
|
2531
|
+
setDone(false);
|
|
2532
|
+
resetForm();
|
|
2533
|
+
}, 300);
|
|
926
2534
|
};
|
|
927
|
-
|
|
928
|
-
|
|
2535
|
+
const next = () => setStep(step + 1);
|
|
2536
|
+
const back = () => setStep(step - 1);
|
|
2537
|
+
const rawSecurityNumber = securityNumber.replace(/\D/g, "");
|
|
2538
|
+
const stepComponents = [
|
|
2539
|
+
/* @__PURE__ */ jsx25(StepPersonalDataForm_default, { securityNumber: rawSecurityNumber, onNext: next }),
|
|
2540
|
+
/* @__PURE__ */ jsx25(
|
|
2541
|
+
StepAddressForm_default,
|
|
2542
|
+
{
|
|
2543
|
+
securityNumber: rawSecurityNumber,
|
|
2544
|
+
onNext: next,
|
|
2545
|
+
onBack: back
|
|
2546
|
+
}
|
|
2547
|
+
),
|
|
2548
|
+
/* @__PURE__ */ jsx25(
|
|
2549
|
+
StepGenderForm_default,
|
|
2550
|
+
{
|
|
2551
|
+
securityNumber: rawSecurityNumber,
|
|
2552
|
+
onNext: next,
|
|
2553
|
+
onBack: back
|
|
2554
|
+
}
|
|
2555
|
+
),
|
|
2556
|
+
/* @__PURE__ */ jsx25(
|
|
2557
|
+
StepDoctorForm_default,
|
|
2558
|
+
{
|
|
2559
|
+
securityNumber: rawSecurityNumber,
|
|
2560
|
+
onNext: next,
|
|
2561
|
+
onBack: back
|
|
2562
|
+
}
|
|
2563
|
+
),
|
|
2564
|
+
/* @__PURE__ */ jsx25(
|
|
2565
|
+
StepAcceptancesForm_default,
|
|
2566
|
+
{
|
|
2567
|
+
securityNumber: rawSecurityNumber,
|
|
2568
|
+
onBack: back,
|
|
2569
|
+
onDone: () => setDone(true)
|
|
2570
|
+
}
|
|
2571
|
+
)
|
|
2572
|
+
];
|
|
2573
|
+
return /* @__PURE__ */ jsxs21(
|
|
2574
|
+
"main",
|
|
929
2575
|
{
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
2576
|
+
className: classNames13(
|
|
2577
|
+
"fixed inset-0 flex items-center justify-end z-50 flex-col transition-all shadow bg-black/40",
|
|
2578
|
+
{
|
|
2579
|
+
"opacity-100 pointer-events-auto": modal.id === ID && modal.open,
|
|
2580
|
+
"opacity-0 pointer-events-none": modal.id !== ID || !modal.open
|
|
2581
|
+
}
|
|
2582
|
+
),
|
|
934
2583
|
children: [
|
|
935
|
-
/* @__PURE__ */
|
|
936
|
-
/* @__PURE__ */
|
|
937
|
-
|
|
2584
|
+
/* @__PURE__ */ jsx25("div", { className: "absolute inset-0", onClick: closeModal }),
|
|
2585
|
+
/* @__PURE__ */ jsxs21("section", { className: "z-10 bg-white flex flex-col p-6 rounded-2xl w-full max-w-md mx-4 shadow-xl max-h-[90vh] overflow-y-auto", children: [
|
|
2586
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between mb-4", children: [
|
|
2587
|
+
/* @__PURE__ */ jsx25(Title_default, { textSize: "18px", textAlign: "start", children: done ? "Tudo pronto!" : "Benef\xEDcio de Farm\xE1cia" }),
|
|
2588
|
+
/* @__PURE__ */ jsx25(
|
|
2589
|
+
"button",
|
|
2590
|
+
{
|
|
2591
|
+
onClick: closeModal,
|
|
2592
|
+
className: "flex h-7 w-7 cursor-pointer items-center justify-center rounded-full text-gray-400 hover:bg-gray-100 hover:text-gray-600 transition-all",
|
|
2593
|
+
children: /* @__PURE__ */ jsx25("svg", { className: "h-4 w-4", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx25(
|
|
2594
|
+
"path",
|
|
2595
|
+
{
|
|
2596
|
+
d: "M1 1l12 12M13 1L1 13",
|
|
2597
|
+
stroke: "currentColor",
|
|
2598
|
+
strokeWidth: "2",
|
|
2599
|
+
strokeLinecap: "round"
|
|
2600
|
+
}
|
|
2601
|
+
) })
|
|
2602
|
+
}
|
|
2603
|
+
)
|
|
2604
|
+
] }),
|
|
2605
|
+
!done && /* @__PURE__ */ jsx25(StepProgress_default, { current: step }),
|
|
2606
|
+
done ? /* @__PURE__ */ jsx25(SuccessScreen_default, { onClose: closeModal }) : stepComponents[step]
|
|
2607
|
+
] })
|
|
938
2608
|
]
|
|
939
2609
|
}
|
|
940
2610
|
);
|
|
941
|
-
}
|
|
942
|
-
var SecurityNumberRegitered_default = SecurityNumberRegitered;
|
|
943
|
-
|
|
944
|
-
// src/components/Errors/ErrorToApplyBenefits.tsx
|
|
945
|
-
import { RefreshCw } from "lucide-react";
|
|
946
|
-
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
947
|
-
var ErrorToApplyBenefits = () => {
|
|
948
|
-
const { ErrorMessage } = useError();
|
|
949
|
-
const { setState } = usePBMStore();
|
|
950
|
-
return /* @__PURE__ */ jsxs10(Container_default, { variant: "main", children: [
|
|
951
|
-
/* @__PURE__ */ jsx14(Title_default, { children: "Erro ao Aplicar o Benef\xEDcio" }),
|
|
952
|
-
/* @__PURE__ */ jsx14(Text_default, { textAlign: "center", children: ErrorMessage }),
|
|
953
|
-
/* @__PURE__ */ jsxs10(
|
|
954
|
-
Button_default,
|
|
955
|
-
{
|
|
956
|
-
className: "bg-transparent p-0 pl-2 w-auto h-auto underline cursor-pointer hover:bg-transparent flex items-center justify-start gap-1",
|
|
957
|
-
style: { color: "var(--pbm-text)" },
|
|
958
|
-
onMouseOver: (e) => e.currentTarget.style.filter = "brightness(0.8)",
|
|
959
|
-
onMouseOut: (e) => e.currentTarget.style.filter = "none",
|
|
960
|
-
onClick: () => setState("isEmpty"),
|
|
961
|
-
id: "check_benefits_button",
|
|
962
|
-
children: [
|
|
963
|
-
/* @__PURE__ */ jsx14("span", { children: "Tentar novamente" }),
|
|
964
|
-
/* @__PURE__ */ jsx14(RefreshCw, { size: 16 })
|
|
965
|
-
]
|
|
966
|
-
}
|
|
967
|
-
)
|
|
968
|
-
] });
|
|
969
2611
|
};
|
|
970
|
-
var
|
|
2612
|
+
var CustomerNotRegistered_default = CustomerNotRegistered;
|
|
971
2613
|
|
|
972
2614
|
// src/components/UI/Link/index.tsx
|
|
973
|
-
import
|
|
2615
|
+
import classNames14 from "classnames";
|
|
974
2616
|
|
|
975
2617
|
// src/utils/getParams.ts
|
|
976
2618
|
var getParams = (params) => {
|
|
@@ -979,16 +2621,16 @@ var getParams = (params) => {
|
|
|
979
2621
|
};
|
|
980
2622
|
|
|
981
2623
|
// src/components/UI/Link/index.tsx
|
|
982
|
-
import { jsx as
|
|
2624
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
983
2625
|
function Link(props) {
|
|
984
2626
|
const { setState } = usePBMStore();
|
|
985
|
-
return /* @__PURE__ */
|
|
2627
|
+
return /* @__PURE__ */ jsx26(
|
|
986
2628
|
"a",
|
|
987
2629
|
{
|
|
988
2630
|
...props,
|
|
989
2631
|
target: props.target || "_self",
|
|
990
2632
|
href: typeof props.href === "string" ? props.href : props.href.pathname + getParams(props.href.param),
|
|
991
|
-
className:
|
|
2633
|
+
className: classNames14(
|
|
992
2634
|
"w-3xs cursor-pointer h-10 rounded-lg text-white text-sm font-semibold transition-colors flex items-center justify-center",
|
|
993
2635
|
props.className
|
|
994
2636
|
),
|
|
@@ -1004,55 +2646,75 @@ function Link(props) {
|
|
|
1004
2646
|
}
|
|
1005
2647
|
var Link_default = Link;
|
|
1006
2648
|
|
|
1007
|
-
// src/components/
|
|
1008
|
-
import
|
|
1009
|
-
import { jsx as
|
|
1010
|
-
var
|
|
2649
|
+
// src/components/Modals/ShopperIsNotAuthenticated.tsx
|
|
2650
|
+
import classNames15 from "classnames";
|
|
2651
|
+
import { jsx as jsx27, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2652
|
+
var ShopperIsNotAuthenticated = ({ ID }) => {
|
|
1011
2653
|
const { customLoginUrl } = usePBMStore();
|
|
1012
2654
|
const { modal, setModal } = useModal();
|
|
1013
|
-
return /* @__PURE__ */
|
|
1014
|
-
"
|
|
2655
|
+
return /* @__PURE__ */ jsxs22(
|
|
2656
|
+
"main",
|
|
1015
2657
|
{
|
|
1016
|
-
|
|
1017
|
-
|
|
2658
|
+
className: classNames15(
|
|
2659
|
+
"fixed inset-0 flex items-center justify-center z-50 flex-col transition-all shadow bg-black/40",
|
|
2660
|
+
{
|
|
2661
|
+
"opacity-100 pointer-events-auto": modal.id === ID && modal.open,
|
|
2662
|
+
"opacity-0 pointer-events-none": modal.id != ID || !modal.open
|
|
2663
|
+
}
|
|
2664
|
+
),
|
|
2665
|
+
children: [
|
|
2666
|
+
/* @__PURE__ */ jsx27(
|
|
2667
|
+
"div",
|
|
2668
|
+
{
|
|
2669
|
+
className: "absolute inset-0",
|
|
2670
|
+
onClick: () => setModal({ id: "", open: false })
|
|
2671
|
+
}
|
|
2672
|
+
),
|
|
2673
|
+
/* @__PURE__ */ jsxs22("section", { className: "z-10 bg-white gap-2 flex-col items-center-safe justify-center-safe p-8 rounded-xl", children: [
|
|
2674
|
+
/* @__PURE__ */ jsx27(
|
|
2675
|
+
Title_default,
|
|
2676
|
+
{
|
|
2677
|
+
textColor: "tomato",
|
|
2678
|
+
textSize: "18px",
|
|
2679
|
+
textAlign: "center",
|
|
2680
|
+
className: "mb-2",
|
|
2681
|
+
children: "Opa! Parece que voc\xEA n\xE3o est\xE1 Logado"
|
|
2682
|
+
}
|
|
2683
|
+
),
|
|
2684
|
+
/* @__PURE__ */ jsxs22(Text_default, { className: "mb-2", textAlign: "center", children: [
|
|
2685
|
+
"Para aproveitar os benef\xEDcios \xE9 necess\xE1rio realizar o",
|
|
2686
|
+
" ",
|
|
2687
|
+
/* @__PURE__ */ jsx27("strong", { children: "Login" }),
|
|
2688
|
+
" ou ",
|
|
2689
|
+
/* @__PURE__ */ jsx27("strong", { children: "Cadastro" }),
|
|
2690
|
+
" no site!"
|
|
2691
|
+
] }),
|
|
2692
|
+
/* @__PURE__ */ jsxs22("section", { className: "flex items-center-safe justify-center-safe gap-4", children: [
|
|
2693
|
+
/* @__PURE__ */ jsx27(
|
|
2694
|
+
Button_default,
|
|
2695
|
+
{
|
|
2696
|
+
className: "bg-gray-600 hover:bg-gray-500",
|
|
2697
|
+
onClick: () => setModal({ id: "", open: false }),
|
|
2698
|
+
children: "Seguir sem Benef\xEDcios"
|
|
2699
|
+
}
|
|
2700
|
+
),
|
|
2701
|
+
/* @__PURE__ */ jsx27(Link_default, { href: customLoginUrl || "/login", children: "Aproveitar Benef\xEDcios" })
|
|
2702
|
+
] })
|
|
2703
|
+
] })
|
|
2704
|
+
]
|
|
1018
2705
|
}
|
|
1019
|
-
)
|
|
1020
|
-
/* @__PURE__ */ jsx16("div", { className: "absolute inset-0", onClick: () => setModal({ id: "", open: false }) }),
|
|
1021
|
-
/* @__PURE__ */ jsxs11("section", { className: "z-10 bg-white gap-2 flex-col items-center-safe justify-center-safe p-8 rounded-xl", children: [
|
|
1022
|
-
/* @__PURE__ */ jsx16(Title_default, { textColor: "tomato", textSize: "18px", textAlign: "center", className: "mb-2", children: "Opa! Parece que voc\xEA n\xE3o est\xE1 Logado" }),
|
|
1023
|
-
/* @__PURE__ */ jsxs11(Text_default, { className: "mb-2", textAlign: "center", children: [
|
|
1024
|
-
"Para aproveitar os benef\xEDcios \xE9 necess\xE1rio realizar o ",
|
|
1025
|
-
/* @__PURE__ */ jsx16("strong", { children: "Login" }),
|
|
1026
|
-
" ou ",
|
|
1027
|
-
/* @__PURE__ */ jsx16("strong", { children: "Cadastro" }),
|
|
1028
|
-
" no site!"
|
|
1029
|
-
] }),
|
|
1030
|
-
/* @__PURE__ */ jsxs11("section", { className: "flex items-center-safe justify-center-safe gap-4", children: [
|
|
1031
|
-
/* @__PURE__ */ jsx16(Button_default, { className: "bg-gray-600 hover:bg-gray-500", onClick: () => setModal({ id: "", open: false }), children: "Seguir sem Benef\xEDcios" }),
|
|
1032
|
-
/* @__PURE__ */ jsx16(Link_default, { href: customLoginUrl || "/login", children: "Aproveitar Benef\xEDcios" })
|
|
1033
|
-
] })
|
|
1034
|
-
] })
|
|
1035
|
-
] });
|
|
2706
|
+
);
|
|
1036
2707
|
};
|
|
1037
|
-
var
|
|
2708
|
+
var ShopperIsNotAuthenticated_default = ShopperIsNotAuthenticated;
|
|
1038
2709
|
|
|
1039
2710
|
// src/PBM.tsx
|
|
1040
2711
|
import Skeleton from "@mui/material/Skeleton";
|
|
1041
2712
|
|
|
1042
|
-
// src/utils/format-price.ts
|
|
1043
|
-
var formatedPrice = (price) => {
|
|
1044
|
-
const result = Number(String(price).replace(",", "."));
|
|
1045
|
-
return result;
|
|
1046
|
-
};
|
|
1047
|
-
|
|
1048
|
-
// src/PBM.tsx
|
|
1049
|
-
import { useTransition as useTransition2 } from "react";
|
|
1050
|
-
|
|
1051
2713
|
// src/hooks/useAppStartup.tsx
|
|
1052
|
-
import { useEffect as
|
|
2714
|
+
import { useEffect as useEffect4, useState as useState10 } from "react";
|
|
1053
2715
|
|
|
1054
2716
|
// src/services/authorization.ts
|
|
1055
|
-
import
|
|
2717
|
+
import Cookies11 from "js-cookie";
|
|
1056
2718
|
|
|
1057
2719
|
// src/services/clients-config.ts
|
|
1058
2720
|
var CLIENTS_CONFIG = {
|
|
@@ -1073,10 +2735,13 @@ var GetAuthorization = async ({ tenant_id }) => {
|
|
|
1073
2735
|
method: "POST",
|
|
1074
2736
|
headers: {
|
|
1075
2737
|
"Content-Type": "application/json",
|
|
1076
|
-
"Accept
|
|
1077
|
-
"
|
|
2738
|
+
"Accept": "application/json",
|
|
2739
|
+
"Accept-Encoding": "gzip, deflate, br"
|
|
1078
2740
|
},
|
|
1079
|
-
credentials: "include"
|
|
2741
|
+
credentials: "include",
|
|
2742
|
+
body: JSON.stringify({
|
|
2743
|
+
accessToken: client.access_token
|
|
2744
|
+
})
|
|
1080
2745
|
}
|
|
1081
2746
|
);
|
|
1082
2747
|
const data = await response.json();
|
|
@@ -1084,7 +2749,7 @@ var GetAuthorization = async ({ tenant_id }) => {
|
|
|
1084
2749
|
throw new Error("Authorization failed");
|
|
1085
2750
|
}
|
|
1086
2751
|
const SECONDS_IN_A_DAY = 86400;
|
|
1087
|
-
|
|
2752
|
+
Cookies11.set("pbm-token", data.data.access_token, {
|
|
1088
2753
|
secure: true,
|
|
1089
2754
|
sameSite: "Strict",
|
|
1090
2755
|
expires: data.data.expires_in / SECONDS_IN_A_DAY
|
|
@@ -1093,10 +2758,10 @@ var GetAuthorization = async ({ tenant_id }) => {
|
|
|
1093
2758
|
};
|
|
1094
2759
|
|
|
1095
2760
|
// src/services/get-product-by-ean.ts
|
|
1096
|
-
import
|
|
2761
|
+
import Cookies12 from "js-cookie";
|
|
1097
2762
|
var GetProductByEAN = async ({ PRODUCT_EAN }) => {
|
|
1098
2763
|
const API_URL = getEnv("VITE_API_URL");
|
|
1099
|
-
const AUTH_TOKEN =
|
|
2764
|
+
const AUTH_TOKEN = Cookies12.get("pbm-token");
|
|
1100
2765
|
if (!AUTH_TOKEN) {
|
|
1101
2766
|
throw new Error("Token is not defined in cookies or is expired");
|
|
1102
2767
|
}
|
|
@@ -1115,10 +2780,10 @@ var GetProductByEAN = async ({ PRODUCT_EAN }) => {
|
|
|
1115
2780
|
};
|
|
1116
2781
|
|
|
1117
2782
|
// src/services/get-list-products.ts
|
|
1118
|
-
import
|
|
2783
|
+
import Cookies13 from "js-cookie";
|
|
1119
2784
|
var GetProductsWithBenefits = async (eanProduct) => {
|
|
1120
2785
|
const API_URL = getEnv("VITE_API_URL");
|
|
1121
|
-
const AUTH_TOKEN =
|
|
2786
|
+
const AUTH_TOKEN = Cookies13.get("pbm-token");
|
|
1122
2787
|
if (!AUTH_TOKEN) {
|
|
1123
2788
|
throw new Error("Token is not defined in cookies or is expired");
|
|
1124
2789
|
}
|
|
@@ -1170,9 +2835,9 @@ var useAppStartup = (props) => {
|
|
|
1170
2835
|
setCustomLoginUrl
|
|
1171
2836
|
} = usePBMStore();
|
|
1172
2837
|
const { setTheme } = useTheme();
|
|
1173
|
-
const [IsReady, setIsReady] =
|
|
1174
|
-
const [IsValid, setIsValid] =
|
|
1175
|
-
const [EanProductExist, setEanProductExist] =
|
|
2838
|
+
const [IsReady, setIsReady] = useState10(false);
|
|
2839
|
+
const [IsValid, setIsValid] = useState10(false);
|
|
2840
|
+
const [EanProductExist, setEanProductExist] = useState10(true);
|
|
1176
2841
|
const fetchAuthorizationRequest = async () => {
|
|
1177
2842
|
try {
|
|
1178
2843
|
const response = await GetAuthorization({ tenant_id: props.tenant_id });
|
|
@@ -1236,7 +2901,7 @@ var useAppStartup = (props) => {
|
|
|
1236
2901
|
setEanProductExist(false);
|
|
1237
2902
|
}
|
|
1238
2903
|
};
|
|
1239
|
-
|
|
2904
|
+
useEffect4(() => {
|
|
1240
2905
|
let isMounted = true;
|
|
1241
2906
|
const startup = async () => {
|
|
1242
2907
|
if (props.theme) {
|
|
@@ -1260,128 +2925,19 @@ var useAppStartup = (props) => {
|
|
|
1260
2925
|
};
|
|
1261
2926
|
var useAppStartup_default = useAppStartup;
|
|
1262
2927
|
|
|
1263
|
-
// src/components/Iframe/index.tsx
|
|
1264
|
-
import classNames10 from "classnames";
|
|
1265
|
-
import { TriangleAlert, ExternalLink } from "lucide-react";
|
|
1266
|
-
import { useState as useState4, useEffect as useEffect4 } from "react";
|
|
1267
|
-
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1268
|
-
function Iframe() {
|
|
1269
|
-
const [showFallback, setShowFallback] = useState4(false);
|
|
1270
|
-
const { setState } = usePBMStore();
|
|
1271
|
-
const { resetModal, modal } = useModal();
|
|
1272
|
-
const isOpen = modal.open && modal.id === "iframe_pbm";
|
|
1273
|
-
useEffect4(() => {
|
|
1274
|
-
if (isOpen) {
|
|
1275
|
-
setShowFallback(false);
|
|
1276
|
-
}
|
|
1277
|
-
}, [isOpen, modal.url]);
|
|
1278
|
-
const handleOpenInNewWindow = () => {
|
|
1279
|
-
if (modal.url) {
|
|
1280
|
-
window.open(modal.url, "_blank", "noopener,noreferrer");
|
|
1281
|
-
}
|
|
1282
|
-
};
|
|
1283
|
-
const handleClose = () => {
|
|
1284
|
-
setState("isEmpty");
|
|
1285
|
-
resetModal();
|
|
1286
|
-
};
|
|
1287
|
-
if (!modal.url) return;
|
|
1288
|
-
return /* @__PURE__ */ jsxs12(
|
|
1289
|
-
"main",
|
|
1290
|
-
{
|
|
1291
|
-
className: classNames10(
|
|
1292
|
-
"fixed inset-0 flex items-center justify-center z-50 flex-col transition-all duration-300 pt-[10%]",
|
|
1293
|
-
isOpen ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
|
|
1294
|
-
),
|
|
1295
|
-
id: "iframe_pbm",
|
|
1296
|
-
children: [
|
|
1297
|
-
/* @__PURE__ */ jsx17(
|
|
1298
|
-
"div",
|
|
1299
|
-
{
|
|
1300
|
-
className: "bg-black/40 inset-0 absolute backdrop-blur-sm",
|
|
1301
|
-
onClick: handleClose
|
|
1302
|
-
}
|
|
1303
|
-
),
|
|
1304
|
-
/* @__PURE__ */ jsxs12("section", { className: "w-[90%] md:w-4/5 gap-4 h-auto bg-zinc-900 py-3 px-6 flex items-center justify-end rounded-t-2xl border-b border-white/10 z-10 shadow-2xl", children: [
|
|
1305
|
-
/* @__PURE__ */ jsx17(
|
|
1306
|
-
Button_default,
|
|
1307
|
-
{
|
|
1308
|
-
onClick: handleClose,
|
|
1309
|
-
className: "bg-red-500 hover:bg-red-400 w-auto px-6 h-9 transition-all active:scale-95 shadow-lg text-xs md:text-sm",
|
|
1310
|
-
children: "Cancelar"
|
|
1311
|
-
}
|
|
1312
|
-
),
|
|
1313
|
-
/* @__PURE__ */ jsx17(
|
|
1314
|
-
Button_default,
|
|
1315
|
-
{
|
|
1316
|
-
onClick: handleClose,
|
|
1317
|
-
className: "bg-blue-600 hover:bg-blue-500 w-auto px-6 h-9 transition-all active:scale-95 shadow-lg text-xs md:text-sm",
|
|
1318
|
-
children: "Finalizei o formul\xE1rio"
|
|
1319
|
-
}
|
|
1320
|
-
)
|
|
1321
|
-
] }),
|
|
1322
|
-
/* @__PURE__ */ jsx17("div", { className: "w-[90%] md:w-4/5 h-[60vh] bg-zinc-900 z-10 overflow-hidden relative shadow-2xl", children: showFallback ? /* @__PURE__ */ jsxs12("div", { className: "absolute inset-0 flex flex-col items-center justify-center p-8 text-center bg-zinc-900", children: [
|
|
1323
|
-
/* @__PURE__ */ jsx17("div", { className: "bg-yellow-500/10 p-4 rounded-full mb-4 animate-pulse", children: /* @__PURE__ */ jsx17(TriangleAlert, { size: 48, className: "text-yellow-500" }) }),
|
|
1324
|
-
/* @__PURE__ */ jsx17(Title_default, { textColor: "white", textSize: "20px", textAlign: "center", className: "mb-2", children: "N\xE3o foi poss\xEDvel carregar o conte\xFAdo" }),
|
|
1325
|
-
/* @__PURE__ */ jsx17(Text_default, { textColor: "#a1a1aa", textAlign: "center", className: "mb-8 max-w-md", children: "Este conte\xFAdo n\xE3o permite exibi\xE7\xE3o integrada por seguran\xE7a. Clique no bot\xE3o abaixo para concluir em uma nova aba." }),
|
|
1326
|
-
/* @__PURE__ */ jsxs12(
|
|
1327
|
-
Button_default,
|
|
1328
|
-
{
|
|
1329
|
-
onClick: handleOpenInNewWindow,
|
|
1330
|
-
className: "flex items-center gap-2 w-auto px-8 h-12 shadow-xl shadow-emerald-500/20",
|
|
1331
|
-
children: [
|
|
1332
|
-
/* @__PURE__ */ jsx17(ExternalLink, { size: 18 }),
|
|
1333
|
-
"Abrir em nova janela"
|
|
1334
|
-
]
|
|
1335
|
-
}
|
|
1336
|
-
)
|
|
1337
|
-
] }) : /* @__PURE__ */ jsx17(
|
|
1338
|
-
"iframe",
|
|
1339
|
-
{
|
|
1340
|
-
src: modal.url,
|
|
1341
|
-
title: modal.label ?? "Conte\xFAdo PBM",
|
|
1342
|
-
className: "w-full h-full border-none bg-white animate-fade-in",
|
|
1343
|
-
allowFullScreen: true,
|
|
1344
|
-
onError: () => setShowFallback(true)
|
|
1345
|
-
}
|
|
1346
|
-
) }),
|
|
1347
|
-
/* @__PURE__ */ jsxs12("section", { className: "w-[90%] md:w-4/5 flex flex-col md:flex-row items-center justify-between gap-3 bg-zinc-900 py-4 px-6 rounded-b-2xl border-t border-white/5 z-10 shadow-2xl", children: [
|
|
1348
|
-
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
|
|
1349
|
-
/* @__PURE__ */ jsx17(TriangleAlert, { size: 18, className: "text-yellow-500 shrink-0" }),
|
|
1350
|
-
/* @__PURE__ */ jsxs12(Text_default, { textColor: "white", className: "text-[10px] md:text-xs", children: [
|
|
1351
|
-
/* @__PURE__ */ jsx17("span", { className: "text-yellow-500 font-bold mr-1", children: "Importante:" }),
|
|
1352
|
-
"Se a p\xE1gina n\xE3o carregar, tente abrir em tela cheia usando o bot\xE3o ao lado."
|
|
1353
|
-
] })
|
|
1354
|
-
] }),
|
|
1355
|
-
/* @__PURE__ */ jsxs12(
|
|
1356
|
-
"button",
|
|
1357
|
-
{
|
|
1358
|
-
onClick: handleOpenInNewWindow,
|
|
1359
|
-
className: "text-white/60 hover:text-white text-[11px] underline flex items-center gap-1 transition-colors cursor-pointer",
|
|
1360
|
-
children: [
|
|
1361
|
-
/* @__PURE__ */ jsx17(ExternalLink, { size: 14 }),
|
|
1362
|
-
" Abrir em nova aba"
|
|
1363
|
-
]
|
|
1364
|
-
}
|
|
1365
|
-
)
|
|
1366
|
-
] })
|
|
1367
|
-
]
|
|
1368
|
-
}
|
|
1369
|
-
);
|
|
1370
|
-
}
|
|
1371
|
-
var Iframe_default = Iframe;
|
|
1372
|
-
|
|
1373
2928
|
// src/PBM.tsx
|
|
1374
|
-
import {
|
|
2929
|
+
import { useTransition as useTransition2 } from "react";
|
|
2930
|
+
import { Fragment as Fragment3, jsx as jsx28, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
1375
2931
|
function PBM(props) {
|
|
1376
2932
|
const { state } = usePBMStore();
|
|
1377
2933
|
const { IsReady, EanProductExist, IsValid } = useAppStartup_default(props);
|
|
1378
2934
|
const { setErrorMessage } = useError();
|
|
1379
2935
|
const theme = useTheme();
|
|
1380
2936
|
const [isPending, startTransition] = useTransition2();
|
|
1381
|
-
const formatedProductPrice =
|
|
2937
|
+
const formatedProductPrice = formaters.price(props.original_product_price);
|
|
1382
2938
|
if (!IsValid) return;
|
|
1383
2939
|
if (!IsReady) {
|
|
1384
|
-
return /* @__PURE__ */
|
|
2940
|
+
return /* @__PURE__ */ jsx28(
|
|
1385
2941
|
Skeleton,
|
|
1386
2942
|
{
|
|
1387
2943
|
variant: "rectangular",
|
|
@@ -1395,9 +2951,9 @@ function PBM(props) {
|
|
|
1395
2951
|
setErrorMessage(
|
|
1396
2952
|
"O produto n\xE3o foi encontrado no sistema. Por favor, tente novamente mais tarde ou contate o suporte."
|
|
1397
2953
|
);
|
|
1398
|
-
return /* @__PURE__ */
|
|
2954
|
+
return /* @__PURE__ */ jsx28("div", { id: "pbm-library-root", children: /* @__PURE__ */ jsx28(ErrorToApplyBenefits_default, {}) });
|
|
1399
2955
|
}
|
|
1400
|
-
return /* @__PURE__ */
|
|
2956
|
+
return /* @__PURE__ */ jsxs23(
|
|
1401
2957
|
"div",
|
|
1402
2958
|
{
|
|
1403
2959
|
id: "pbm-library-root",
|
|
@@ -1409,19 +2965,19 @@ function PBM(props) {
|
|
|
1409
2965
|
"--pbm-border": theme.borderColor
|
|
1410
2966
|
},
|
|
1411
2967
|
children: [
|
|
1412
|
-
/* @__PURE__ */
|
|
1413
|
-
/* @__PURE__ */
|
|
1414
|
-
/* @__PURE__ */
|
|
1415
|
-
state === "isEmpty" && /* @__PURE__ */
|
|
1416
|
-
state === "isInvalid" && /* @__PURE__ */
|
|
1417
|
-
state === "isRegistered" && /* @__PURE__ */
|
|
1418
|
-
(state === "isActivated" || state === "isPreview") && /* @__PURE__ */
|
|
1419
|
-
state === "isError" && /* @__PURE__ */
|
|
1420
|
-
] }) })
|
|
1421
|
-
/* @__PURE__ */ jsx18(Footer_default, {})
|
|
2968
|
+
/* @__PURE__ */ jsxs23(Container_default, { variant: "main", children: [
|
|
2969
|
+
/* @__PURE__ */ jsx28(Header_default, { originalProductPrice: formatedProductPrice || 0 }),
|
|
2970
|
+
/* @__PURE__ */ jsx28(Container_default, { variant: "simple", children: isPending ? /* @__PURE__ */ jsx28(Loading_default, {}) : /* @__PURE__ */ jsxs23(Fragment3, { children: [
|
|
2971
|
+
state === "isEmpty" && /* @__PURE__ */ jsx28(Form_default, { startTransition }),
|
|
2972
|
+
state === "isInvalid" && /* @__PURE__ */ jsx28(SecurityNumberInvalid_default, {}),
|
|
2973
|
+
state === "isRegistered" && /* @__PURE__ */ jsx28(SecurityNumberRegitered_default, {}),
|
|
2974
|
+
(state === "isActivated" || state === "isPreview") && /* @__PURE__ */ jsx28(BenefitsTable_default, {}),
|
|
2975
|
+
state === "isError" && /* @__PURE__ */ jsx28(ErrorToApplyBenefits_default, {})
|
|
2976
|
+
] }) })
|
|
1422
2977
|
] }),
|
|
1423
|
-
/* @__PURE__ */
|
|
1424
|
-
/* @__PURE__ */
|
|
2978
|
+
/* @__PURE__ */ jsx28(ShopperIsNotAuthenticated_default, { ID: "ShopperIsNotAuthenticated" }),
|
|
2979
|
+
/* @__PURE__ */ jsx28(CustomerNotRegistered_default, { ID: "CustomerNotRegistered" }),
|
|
2980
|
+
/* @__PURE__ */ jsx28(Iframe_default, {})
|
|
1425
2981
|
]
|
|
1426
2982
|
}
|
|
1427
2983
|
);
|