pager-widget 0.2.6 → 0.2.7
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/App.jsx +1149 -981
- package/ConsentPopup.jsx +265 -94
- package/Dropdown.jsx +36 -23
- package/InputConverter.jsx +45 -42
- package/dist/lib.js +3144 -10
- package/md/assistant_md.js +32 -22
- package/package.json +2 -1
package/InputConverter.jsx
CHANGED
|
@@ -13,10 +13,10 @@ const InputWrapper = styled.div`
|
|
|
13
13
|
border-radius: 8px;
|
|
14
14
|
border: 1px solid
|
|
15
15
|
${({ error }) =>
|
|
16
|
-
error === "true" ? "var(--red-300, #FFA2A2)" : "
|
|
16
|
+
error === "true" ? "var(--red-300, #FFA2A2)" : "transparent"};
|
|
17
17
|
background: #fff;
|
|
18
18
|
outline: none;
|
|
19
|
-
height:
|
|
19
|
+
height: 36px;
|
|
20
20
|
width: 100%;
|
|
21
21
|
text-indent: 12px;
|
|
22
22
|
padding-right: 40px; /* Space for icon */
|
|
@@ -42,7 +42,7 @@ const InputWrapper = styled.div`
|
|
|
42
42
|
`;
|
|
43
43
|
|
|
44
44
|
const Form = styled.form`
|
|
45
|
-
margin
|
|
45
|
+
margin: 0px;
|
|
46
46
|
`;
|
|
47
47
|
|
|
48
48
|
Form.Field = styled.div`
|
|
@@ -50,19 +50,20 @@ Form.Field = styled.div`
|
|
|
50
50
|
`;
|
|
51
51
|
|
|
52
52
|
Form.Wrapper = styled.div`
|
|
53
|
-
padding:
|
|
53
|
+
padding: 14px 16px 16px 14px;
|
|
54
54
|
maxwidth: "600px";
|
|
55
55
|
margin: 0 auto;
|
|
56
56
|
`;
|
|
57
57
|
|
|
58
58
|
const Label = styled.label`
|
|
59
59
|
display: block;
|
|
60
|
-
margin-bottom:
|
|
60
|
+
margin-bottom: 6px;
|
|
61
|
+
color: #314158;
|
|
61
62
|
font-size: 14px;
|
|
62
|
-
font-
|
|
63
|
+
font-style: normal;
|
|
64
|
+
font-weight: 600;
|
|
63
65
|
line-height: 20px;
|
|
64
|
-
|
|
65
|
-
font-family: Inter, Open Sans;
|
|
66
|
+
font-family: "Inter", "Open Sans";
|
|
66
67
|
`;
|
|
67
68
|
|
|
68
69
|
Label.Meta = styled.span`
|
|
@@ -94,13 +95,18 @@ const TextArea = styled.div`
|
|
|
94
95
|
border-radius: 8px;
|
|
95
96
|
border: 1px solid
|
|
96
97
|
${({ error }) =>
|
|
97
|
-
error === "true" ? "var(--red-300, #FFA2A2)" : "
|
|
98
|
+
error === "true" ? "var(--red-300, #FFA2A2)" : "transparent"};
|
|
98
99
|
background: #fff;
|
|
99
100
|
outline: none;
|
|
100
101
|
height: 130px;
|
|
101
102
|
width: 100%;
|
|
102
103
|
text-indent: 12px;
|
|
103
|
-
|
|
104
|
+
font-size: 14px;
|
|
105
|
+
font-style: normal;
|
|
106
|
+
font-weight: 400;
|
|
107
|
+
line-height: normal;
|
|
108
|
+
padding-top: 5px;
|
|
109
|
+
font-family: Inter, Open Sans;
|
|
104
110
|
|
|
105
111
|
:: placeholder {
|
|
106
112
|
color: #98a2b3;
|
|
@@ -108,7 +114,6 @@ const TextArea = styled.div`
|
|
|
108
114
|
font-style: normal;
|
|
109
115
|
font-weight: 400;
|
|
110
116
|
line-height: normal;
|
|
111
|
-
padding-top: 5px;
|
|
112
117
|
font-family: Inter, Open Sans;
|
|
113
118
|
}
|
|
114
119
|
}
|
|
@@ -151,6 +156,7 @@ const InfoIcon = styled.span`
|
|
|
151
156
|
position: relative;
|
|
152
157
|
display: inline-flex;
|
|
153
158
|
align-items: center;
|
|
159
|
+
margin-top: 2px;
|
|
154
160
|
justify-content: center;
|
|
155
161
|
width: 18px;
|
|
156
162
|
height: 18px;
|
|
@@ -222,7 +228,7 @@ const InputConverter = ({
|
|
|
222
228
|
setSourceState,
|
|
223
229
|
}) => {
|
|
224
230
|
const [errors, setErrors] = useState({});
|
|
225
|
-
const endpoint = useContext(EndPointContext)
|
|
231
|
+
const endpoint = useContext(EndPointContext);
|
|
226
232
|
// State to hold form data
|
|
227
233
|
const [formValues, setFormValues] = useState(
|
|
228
234
|
Object.fromEntries(
|
|
@@ -233,8 +239,7 @@ const InputConverter = ({
|
|
|
233
239
|
// const handleChange = (e) => {
|
|
234
240
|
// const { id, value } = e.target;
|
|
235
241
|
// const newErrors = {};
|
|
236
|
-
|
|
237
|
-
|
|
242
|
+
|
|
238
243
|
// setFormValues((prev) => ({
|
|
239
244
|
// ...prev,
|
|
240
245
|
// [id]: value,
|
|
@@ -258,9 +263,8 @@ const InputConverter = ({
|
|
|
258
263
|
// }
|
|
259
264
|
|
|
260
265
|
// setErrors({});
|
|
261
|
-
|
|
262
|
-
// };
|
|
263
266
|
|
|
267
|
+
// };
|
|
264
268
|
|
|
265
269
|
// const handleChange = (e) => {
|
|
266
270
|
// const { id, value } = e.target;
|
|
@@ -269,9 +273,7 @@ const InputConverter = ({
|
|
|
269
273
|
// ...prev,
|
|
270
274
|
// [id]: value,
|
|
271
275
|
// }));
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
276
|
+
|
|
275
277
|
// formData.form_data.form_template.forEach((field) => {
|
|
276
278
|
// if (field.is_mandatory) {
|
|
277
279
|
// if (field.field_type === "country") {
|
|
@@ -283,20 +285,20 @@ const InputConverter = ({
|
|
|
283
285
|
// }
|
|
284
286
|
// }
|
|
285
287
|
// });
|
|
286
|
-
|
|
288
|
+
|
|
287
289
|
// setErrors(newErrors);
|
|
288
290
|
// };
|
|
289
291
|
// const handleChange = (e) => {
|
|
290
292
|
// const { id, value } = e.target;
|
|
291
|
-
|
|
293
|
+
|
|
292
294
|
// setFormValues((prev) => ({
|
|
293
295
|
// ...prev,
|
|
294
296
|
// [id]: value,
|
|
295
297
|
// }));
|
|
296
|
-
|
|
298
|
+
|
|
297
299
|
// // Validate all fields, not just the changed one
|
|
298
300
|
// const newErrors = {};
|
|
299
|
-
|
|
301
|
+
|
|
300
302
|
// formData.form_data.form_template.forEach((field) => {
|
|
301
303
|
// if (field.is_mandatory) {
|
|
302
304
|
// if (field.field_type === "country") {
|
|
@@ -310,28 +312,31 @@ const InputConverter = ({
|
|
|
310
312
|
// }
|
|
311
313
|
// }
|
|
312
314
|
// });
|
|
313
|
-
|
|
315
|
+
|
|
314
316
|
// setErrors(newErrors);
|
|
315
317
|
// };
|
|
316
|
-
|
|
317
318
|
|
|
318
319
|
const handleChange = (e) => {
|
|
319
320
|
const { id, value } = e.target;
|
|
320
|
-
|
|
321
|
+
|
|
321
322
|
// Update form values
|
|
322
323
|
setFormValues((prev) => ({
|
|
323
324
|
...prev,
|
|
324
325
|
[id]: value,
|
|
325
326
|
}));
|
|
326
|
-
|
|
327
|
+
|
|
327
328
|
// Re-validate all fields on every change
|
|
328
329
|
setErrors((prevErrors) => {
|
|
329
330
|
const newErrors = { ...prevErrors };
|
|
330
|
-
|
|
331
|
+
|
|
331
332
|
formData.form_data.form_template.forEach((field) => {
|
|
332
333
|
if (field.is_mandatory) {
|
|
333
334
|
if (field.field_type === "country") {
|
|
334
|
-
if (
|
|
335
|
+
if (
|
|
336
|
+
!formValues.SYS_country &&
|
|
337
|
+
id === "SYS_country" &&
|
|
338
|
+
value === ""
|
|
339
|
+
) {
|
|
335
340
|
newErrors[field.field_id] = `${field.name} is required`;
|
|
336
341
|
} else {
|
|
337
342
|
delete newErrors[field.field_id]; // Remove error when field is filled
|
|
@@ -349,12 +354,10 @@ const InputConverter = ({
|
|
|
349
354
|
}
|
|
350
355
|
}
|
|
351
356
|
});
|
|
352
|
-
|
|
357
|
+
|
|
353
358
|
return newErrors;
|
|
354
359
|
});
|
|
355
360
|
};
|
|
356
|
-
|
|
357
|
-
|
|
358
361
|
|
|
359
362
|
const handleDropChange = (id) => (value) => {
|
|
360
363
|
setFormValues((prev) => ({
|
|
@@ -408,13 +411,9 @@ const InputConverter = ({
|
|
|
408
411
|
};
|
|
409
412
|
|
|
410
413
|
axios
|
|
411
|
-
.post(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
{
|
|
415
|
-
withCredentials: true,
|
|
416
|
-
}
|
|
417
|
-
)
|
|
414
|
+
.post(`${endpoint}/${workspace}/${widget?.id}/lead`, submittedData, {
|
|
415
|
+
withCredentials: true,
|
|
416
|
+
})
|
|
418
417
|
.then((res) => {
|
|
419
418
|
setSourceState(res.data.source_id);
|
|
420
419
|
})
|
|
@@ -432,16 +431,20 @@ const InputConverter = ({
|
|
|
432
431
|
|
|
433
432
|
return (
|
|
434
433
|
<Form.Wrapper
|
|
435
|
-
style={{
|
|
434
|
+
style={{
|
|
435
|
+
padding: "14px 16px 16px 14px",
|
|
436
|
+
maxWidth: "600px",
|
|
437
|
+
margin: "0 auto",
|
|
438
|
+
}}
|
|
436
439
|
>
|
|
437
|
-
<Form onSubmit={handleSubmit}
|
|
440
|
+
<Form onSubmit={handleSubmit}>
|
|
438
441
|
{formData.form_data.form_template.map((field) => (
|
|
439
442
|
<Form.Field key={field.id} style={{ marginBottom: "10px" }}>
|
|
440
443
|
<div
|
|
441
444
|
style={{
|
|
442
445
|
display: "flex",
|
|
443
446
|
flexDirection: "row",
|
|
444
|
-
gap: "
|
|
447
|
+
gap: "6px",
|
|
445
448
|
}}
|
|
446
449
|
>
|
|
447
450
|
<Label htmlFor={field.field_id}>
|