mitre-form-component 0.1.3 → 2.0.0
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/README.md +151 -19
- package/dist/index.cjs +582 -190
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -5
- package/dist/index.d.ts +48 -5
- package/dist/index.js +566 -175
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -300,6 +300,92 @@ var Subtitle = styled.p`
|
|
|
300
300
|
color: ${(props) => props.$textColor || theme.colors.black};
|
|
301
301
|
`;
|
|
302
302
|
|
|
303
|
+
// src/components/ProductSelect/styles.ts
|
|
304
|
+
import styled2, { css } from "styled-components";
|
|
305
|
+
var FormLabel = styled2.label`
|
|
306
|
+
font-family: ${theme.fonts.primary};
|
|
307
|
+
font-style: normal;
|
|
308
|
+
font-weight: 500;
|
|
309
|
+
font-size: 1rem;
|
|
310
|
+
color: ${(props) => props.$textColor || theme.colors.black};
|
|
311
|
+
display: block;
|
|
312
|
+
margin-bottom: 0.5rem;
|
|
313
|
+
text-align: left;
|
|
314
|
+
`;
|
|
315
|
+
var Select = styled2.select`
|
|
316
|
+
font-family: ${theme.fonts.primary};
|
|
317
|
+
font-style: normal;
|
|
318
|
+
font-weight: 500;
|
|
319
|
+
font-size: 1rem;
|
|
320
|
+
line-height: 1.5rem;
|
|
321
|
+
background: ${(props) => props.$backgroundColor || theme.colors.white};
|
|
322
|
+
color: ${(props) => props.$textColor || theme.colors.black};
|
|
323
|
+
padding: 0.5rem 3rem 0.5rem 0.5rem; /* Aumentado padding-right para 3rem */
|
|
324
|
+
border-radius: 0.125rem;
|
|
325
|
+
border: 1px solid ${(props) => props.$borderColor || theme.colors.transparent};
|
|
326
|
+
display: block;
|
|
327
|
+
height: 3.125rem;
|
|
328
|
+
width: 100%;
|
|
329
|
+
cursor: pointer;
|
|
330
|
+
|
|
331
|
+
/* Remover a seta padrão do navegador */
|
|
332
|
+
-webkit-appearance: none;
|
|
333
|
+
-moz-appearance: none;
|
|
334
|
+
appearance: none;
|
|
335
|
+
|
|
336
|
+
/* Adicionar seta personalizada maior */
|
|
337
|
+
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
|
|
338
|
+
background-repeat: no-repeat;
|
|
339
|
+
background-position: right 1rem center; /* Posicionado a 1rem da direita */
|
|
340
|
+
background-size: 1.25rem; /* Tamanho da seta aumentado para 1.25rem */
|
|
341
|
+
|
|
342
|
+
&:focus {
|
|
343
|
+
border-radius: 0.125rem;
|
|
344
|
+
border: 2px solid ${(props) => props.$focusBorderColor || theme.colors.yellow500};
|
|
345
|
+
outline: none;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/* Estilo para option disabled (placeholder) */
|
|
349
|
+
option:disabled {
|
|
350
|
+
color: ${theme.colors.gray100};
|
|
351
|
+
font-weight: 800;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/* Estilo para options normais */
|
|
355
|
+
option:not(:disabled) {
|
|
356
|
+
color: ${(props) => props.$textColor || theme.colors.black};
|
|
357
|
+
font-weight: 500;
|
|
358
|
+
}
|
|
359
|
+
`;
|
|
360
|
+
var FormErrorMessage = styled2.small`
|
|
361
|
+
font-size: 0.75rem;
|
|
362
|
+
line-height: 1.125rem;
|
|
363
|
+
color: ${theme.colors.red};
|
|
364
|
+
margin-top: 0.25rem;
|
|
365
|
+
display: block;
|
|
366
|
+
`;
|
|
367
|
+
var FormControl = styled2.div.withConfig({
|
|
368
|
+
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
369
|
+
})`
|
|
370
|
+
${FormLabel} {
|
|
371
|
+
${(props) => props.isInvalid && css`
|
|
372
|
+
color: ${theme.colors.red};
|
|
373
|
+
`};
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
${Select} {
|
|
377
|
+
${(props) => props.isInvalid && css`
|
|
378
|
+
border: 1px solid ${theme.colors.red};
|
|
379
|
+
`};
|
|
380
|
+
|
|
381
|
+
&:focus {
|
|
382
|
+
${(props) => props.isInvalid && css`
|
|
383
|
+
border: 1px solid ${theme.colors.red};
|
|
384
|
+
`};
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
`;
|
|
388
|
+
|
|
303
389
|
// src/components/styles/FontLoader.tsx
|
|
304
390
|
import { useEffect } from "react";
|
|
305
391
|
var useMontserratFont = () => {
|
|
@@ -369,8 +455,8 @@ function date(e) {
|
|
|
369
455
|
}
|
|
370
456
|
|
|
371
457
|
// src/components/Input/styles.ts
|
|
372
|
-
import
|
|
373
|
-
var
|
|
458
|
+
import styled3, { css as css2 } from "styled-components";
|
|
459
|
+
var FormLabel2 = styled3.label`
|
|
374
460
|
font-family: ${theme.fonts.primary};
|
|
375
461
|
font-style: normal;
|
|
376
462
|
font-weight: 500;
|
|
@@ -380,7 +466,7 @@ var FormLabel = styled2.label`
|
|
|
380
466
|
margin-bottom: 0.5rem;
|
|
381
467
|
text-align: left;
|
|
382
468
|
`;
|
|
383
|
-
var Input =
|
|
469
|
+
var Input = styled3.input`
|
|
384
470
|
font-family: ${theme.fonts.primary};
|
|
385
471
|
font-style: normal;
|
|
386
472
|
font-weight: 500;
|
|
@@ -422,24 +508,24 @@ var Input = styled2.input`
|
|
|
422
508
|
font-weight: 500;
|
|
423
509
|
}
|
|
424
510
|
`;
|
|
425
|
-
var
|
|
511
|
+
var FormErrorMessage2 = styled3.small`
|
|
426
512
|
font-size: 0.75rem;
|
|
427
513
|
line-height: 1.125rem;
|
|
428
514
|
color: ${theme.colors.red};
|
|
429
515
|
margin-top: 0.25rem;
|
|
430
516
|
display: block;
|
|
431
517
|
`;
|
|
432
|
-
var
|
|
518
|
+
var FormControl2 = styled3.div.withConfig({
|
|
433
519
|
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
434
520
|
})`
|
|
435
|
-
${
|
|
436
|
-
${(props) => props.isInvalid &&
|
|
521
|
+
${FormLabel2} {
|
|
522
|
+
${(props) => props.isInvalid && css2`
|
|
437
523
|
color: ${theme.colors.red};
|
|
438
524
|
`};
|
|
439
525
|
}
|
|
440
526
|
|
|
441
527
|
${Input} {
|
|
442
|
-
${(props) => props.isInvalid &&
|
|
528
|
+
${(props) => props.isInvalid && css2`
|
|
443
529
|
border: 1px solid ${theme.colors.red};
|
|
444
530
|
|
|
445
531
|
&:not(:focus)::placeholder {
|
|
@@ -449,7 +535,7 @@ var FormControl = styled2.div.withConfig({
|
|
|
449
535
|
`};
|
|
450
536
|
|
|
451
537
|
&:focus {
|
|
452
|
-
${(props) => props.isInvalid &&
|
|
538
|
+
${(props) => props.isInvalid && css2`
|
|
453
539
|
border: 1px solid ${theme.colors.red};
|
|
454
540
|
`};
|
|
455
541
|
}
|
|
@@ -482,8 +568,8 @@ var InputBase = ({
|
|
|
482
568
|
},
|
|
483
569
|
[mask]
|
|
484
570
|
);
|
|
485
|
-
return /* @__PURE__ */ jsxs(
|
|
486
|
-
!!label && /* @__PURE__ */ jsx(
|
|
571
|
+
return /* @__PURE__ */ jsxs(FormControl2, { isInvalid: !!error, children: [
|
|
572
|
+
!!label && /* @__PURE__ */ jsx(FormLabel2, { htmlFor: id, $textColor: labelTextColor, children: label }),
|
|
487
573
|
!mask ? /* @__PURE__ */ jsx(
|
|
488
574
|
Input,
|
|
489
575
|
{
|
|
@@ -516,15 +602,15 @@ var InputBase = ({
|
|
|
516
602
|
...rest
|
|
517
603
|
}
|
|
518
604
|
),
|
|
519
|
-
!!error && showErrorMessage && /* @__PURE__ */ jsx(
|
|
605
|
+
!!error && showErrorMessage && /* @__PURE__ */ jsx(FormErrorMessage2, { "data-testid": "error-message", children: typeof error === "string" ? error : error.message })
|
|
520
606
|
] });
|
|
521
607
|
};
|
|
522
608
|
var Input2 = forwardRef(InputBase);
|
|
523
609
|
|
|
524
610
|
// src/components/Button/styles.ts
|
|
525
611
|
import { darken } from "polished";
|
|
526
|
-
import
|
|
527
|
-
var Icon =
|
|
612
|
+
import styled4, { css as css3 } from "styled-components";
|
|
613
|
+
var Icon = styled4.span`
|
|
528
614
|
font-size: 0;
|
|
529
615
|
line-height: 0;
|
|
530
616
|
transition: all 0.25s ease;
|
|
@@ -534,7 +620,7 @@ var Icon = styled3.span`
|
|
|
534
620
|
opacity: 0;
|
|
535
621
|
margin-right: 0.625rem;
|
|
536
622
|
`;
|
|
537
|
-
var Text =
|
|
623
|
+
var Text = styled4.span`
|
|
538
624
|
font-family: ${theme.fonts.primary};
|
|
539
625
|
font-size: 1rem;
|
|
540
626
|
line-height: 1.5rem;
|
|
@@ -542,14 +628,14 @@ var Text = styled3.span`
|
|
|
542
628
|
|
|
543
629
|
transition: all 0.25s ease;
|
|
544
630
|
`;
|
|
545
|
-
var TextSubmitting =
|
|
631
|
+
var TextSubmitting = styled4.span`
|
|
546
632
|
font-family: ${theme.fonts.primary};
|
|
547
633
|
font-weight: 400;
|
|
548
634
|
font-size: 1rem;
|
|
549
635
|
|
|
550
636
|
transition: all 0.25s ease;
|
|
551
637
|
`;
|
|
552
|
-
var LoadingIcon =
|
|
638
|
+
var LoadingIcon = styled4.span.withConfig({
|
|
553
639
|
shouldForwardProp: (prop) => prop !== "hasText"
|
|
554
640
|
})`
|
|
555
641
|
display: block;
|
|
@@ -572,7 +658,7 @@ var LoadingIcon = styled3.span.withConfig({
|
|
|
572
658
|
}
|
|
573
659
|
}
|
|
574
660
|
`;
|
|
575
|
-
var Button =
|
|
661
|
+
var Button = styled4.button.withConfig({
|
|
576
662
|
shouldForwardProp: (prop) => ![
|
|
577
663
|
"hasIcon",
|
|
578
664
|
"isSubmitting",
|
|
@@ -629,14 +715,14 @@ var Button = styled3.button.withConfig({
|
|
|
629
715
|
}
|
|
630
716
|
|
|
631
717
|
${Text} {
|
|
632
|
-
${(props) => props.isSubmitting && !props.hasSubmittingMessage &&
|
|
718
|
+
${(props) => props.isSubmitting && !props.hasSubmittingMessage && css3`
|
|
633
719
|
transform: unset;
|
|
634
720
|
opacity: 0;
|
|
635
721
|
`}
|
|
636
722
|
}
|
|
637
723
|
|
|
638
724
|
${LoadingIcon} {
|
|
639
|
-
${(props) => props.isSubmitting && !props.hasSubmittingMessage &&
|
|
725
|
+
${(props) => props.isSubmitting && !props.hasSubmittingMessage && css3`
|
|
640
726
|
display: flex;
|
|
641
727
|
-webkit-box-align: center;
|
|
642
728
|
align-items: center;
|
|
@@ -680,7 +766,7 @@ function Button2({
|
|
|
680
766
|
import { useEffect as useEffect2, useState as useState2, useCallback as useCallback2 } from "react";
|
|
681
767
|
|
|
682
768
|
// src/components/Alert/styles.ts
|
|
683
|
-
import
|
|
769
|
+
import styled5, { css as css4, keyframes } from "styled-components";
|
|
684
770
|
var fadeIn = keyframes`
|
|
685
771
|
from { opacity: 0; transform: translateY(-10px); }
|
|
686
772
|
to { opacity: 1; transform: translateY(0); }
|
|
@@ -690,7 +776,7 @@ var fadeOut = keyframes`
|
|
|
690
776
|
to { opacity: 0; transform: translateY(-10px); }
|
|
691
777
|
`;
|
|
692
778
|
var typeStyles = {
|
|
693
|
-
error:
|
|
779
|
+
error: css4`
|
|
694
780
|
background-color: ${theme.colors.red};
|
|
695
781
|
border: 1px solid ${theme.colors.red};
|
|
696
782
|
color: ${theme.colors.white};
|
|
@@ -698,7 +784,7 @@ var typeStyles = {
|
|
|
698
784
|
color: ${theme.colors.white};
|
|
699
785
|
}
|
|
700
786
|
`,
|
|
701
|
-
warning:
|
|
787
|
+
warning: css4`
|
|
702
788
|
background-color: ${theme.colors.yellow500};
|
|
703
789
|
border: 1px solid ${theme.colors.yellow400};
|
|
704
790
|
color: ${theme.colors.black};
|
|
@@ -706,7 +792,7 @@ var typeStyles = {
|
|
|
706
792
|
color: ${theme.colors.black};
|
|
707
793
|
}
|
|
708
794
|
`,
|
|
709
|
-
info:
|
|
795
|
+
info: css4`
|
|
710
796
|
background-color: ${theme.colors.blue};
|
|
711
797
|
border: 1px solid ${theme.colors.blue};
|
|
712
798
|
color: ${theme.colors.white};
|
|
@@ -714,7 +800,7 @@ var typeStyles = {
|
|
|
714
800
|
color: ${theme.colors.white};
|
|
715
801
|
}
|
|
716
802
|
`,
|
|
717
|
-
success:
|
|
803
|
+
success: css4`
|
|
718
804
|
background-color: ${theme.colors.green};
|
|
719
805
|
border: 1px solid ${theme.colors.green2};
|
|
720
806
|
color: ${theme.colors.white};
|
|
@@ -723,7 +809,7 @@ var typeStyles = {
|
|
|
723
809
|
}
|
|
724
810
|
`
|
|
725
811
|
};
|
|
726
|
-
var AlertContainer =
|
|
812
|
+
var AlertContainer = styled5.div`
|
|
727
813
|
position: fixed;
|
|
728
814
|
width: 500px;
|
|
729
815
|
top: 15px;
|
|
@@ -743,7 +829,7 @@ var AlertContainer = styled4.div`
|
|
|
743
829
|
|
|
744
830
|
${({ $type }) => typeStyles[$type]}
|
|
745
831
|
`;
|
|
746
|
-
var DismissButton =
|
|
832
|
+
var DismissButton = styled5.button`
|
|
747
833
|
position: absolute;
|
|
748
834
|
background: transparent;
|
|
749
835
|
right: 10px;
|
|
@@ -808,16 +894,183 @@ var Alert = ({
|
|
|
808
894
|
);
|
|
809
895
|
};
|
|
810
896
|
|
|
897
|
+
// src/components/Modal/index.tsx
|
|
898
|
+
import { useEffect as useEffect3, useRef } from "react";
|
|
899
|
+
import { HiX as HiX2 } from "react-icons/hi";
|
|
900
|
+
|
|
901
|
+
// src/components/Modal/styles.ts
|
|
902
|
+
import styled6, { css as css5, keyframes as keyframes2 } from "styled-components";
|
|
903
|
+
var fadeIn2 = keyframes2`
|
|
904
|
+
from { opacity: 0; }
|
|
905
|
+
to { opacity: 1; }
|
|
906
|
+
`;
|
|
907
|
+
var slideIn = keyframes2`
|
|
908
|
+
from { opacity: 0; transform: translateY(-20px) scale(0.96); }
|
|
909
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
910
|
+
`;
|
|
911
|
+
var Overlay = styled6.div`
|
|
912
|
+
position: fixed;
|
|
913
|
+
inset: 0;
|
|
914
|
+
background: rgba(0, 0, 0, 0.55);
|
|
915
|
+
display: flex;
|
|
916
|
+
align-items: center;
|
|
917
|
+
justify-content: center;
|
|
918
|
+
z-index: 9999;
|
|
919
|
+
padding: 1rem;
|
|
920
|
+
animation: ${fadeIn2} 0.18s ease-out;
|
|
921
|
+
`;
|
|
922
|
+
var accentStyles = {
|
|
923
|
+
success: css5`
|
|
924
|
+
color: ${theme.colors.green2};
|
|
925
|
+
`,
|
|
926
|
+
error: css5`
|
|
927
|
+
color: ${theme.colors.red};
|
|
928
|
+
`
|
|
929
|
+
};
|
|
930
|
+
var Container = styled6.div`
|
|
931
|
+
position: relative;
|
|
932
|
+
background: ${theme.colors.white};
|
|
933
|
+
border-radius: 0.75rem;
|
|
934
|
+
box-shadow: ${theme.shadows.shadow500};
|
|
935
|
+
max-width: 420px;
|
|
936
|
+
width: 100%;
|
|
937
|
+
padding: 1.75rem 1.5rem 1.25rem;
|
|
938
|
+
font-family: ${theme.fonts.primary};
|
|
939
|
+
animation: ${slideIn} 0.22s ease-out;
|
|
940
|
+
|
|
941
|
+
&::before {
|
|
942
|
+
content: "";
|
|
943
|
+
display: block;
|
|
944
|
+
width: 56px;
|
|
945
|
+
height: 4px;
|
|
946
|
+
border-radius: 999px;
|
|
947
|
+
margin: 0 auto 1rem;
|
|
948
|
+
background: ${({ $type }) => $type === "success" ? theme.colors.green2 : theme.colors.red};
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
h2 {
|
|
952
|
+
margin: 0 0 0.5rem;
|
|
953
|
+
font-size: 1.25rem;
|
|
954
|
+
font-weight: 700;
|
|
955
|
+
text-align: center;
|
|
956
|
+
${({ $type }) => accentStyles[$type]}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
p {
|
|
960
|
+
margin: 0 0 1.5rem;
|
|
961
|
+
font-size: 0.95rem;
|
|
962
|
+
line-height: 1.45;
|
|
963
|
+
text-align: center;
|
|
964
|
+
color: ${theme.colors.black};
|
|
965
|
+
}
|
|
966
|
+
`;
|
|
967
|
+
var CloseButton = styled6.button`
|
|
968
|
+
position: absolute;
|
|
969
|
+
top: 0.5rem;
|
|
970
|
+
right: 0.5rem;
|
|
971
|
+
background: transparent;
|
|
972
|
+
border: none;
|
|
973
|
+
cursor: pointer;
|
|
974
|
+
color: ${theme.colors.gray550};
|
|
975
|
+
padding: 0.25rem;
|
|
976
|
+
display: inline-flex;
|
|
977
|
+
align-items: center;
|
|
978
|
+
justify-content: center;
|
|
979
|
+
border-radius: 999px;
|
|
980
|
+
transition: background 0.15s, color 0.15s;
|
|
981
|
+
|
|
982
|
+
&:hover {
|
|
983
|
+
background: ${theme.colors.gray300};
|
|
984
|
+
color: ${theme.colors.black};
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
svg {
|
|
988
|
+
width: 1.1rem;
|
|
989
|
+
height: 1.1rem;
|
|
990
|
+
}
|
|
991
|
+
`;
|
|
992
|
+
var PrimaryButton = styled6.button`
|
|
993
|
+
display: block;
|
|
994
|
+
width: 100%;
|
|
995
|
+
padding: 0.75rem 1rem;
|
|
996
|
+
border: none;
|
|
997
|
+
border-radius: 0.5rem;
|
|
998
|
+
background: ${({ $bgColor }) => $bgColor || theme.colors.yellow500};
|
|
999
|
+
color: ${({ $textColor }) => $textColor || theme.colors.black};
|
|
1000
|
+
font-family: ${theme.fonts.primary};
|
|
1001
|
+
font-size: 1rem;
|
|
1002
|
+
font-weight: 700;
|
|
1003
|
+
cursor: pointer;
|
|
1004
|
+
transition: filter 0.15s;
|
|
1005
|
+
|
|
1006
|
+
&:hover {
|
|
1007
|
+
filter: brightness(0.95);
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
&:focus-visible {
|
|
1011
|
+
outline: 2px solid ${theme.colors.yellow400};
|
|
1012
|
+
outline-offset: 2px;
|
|
1013
|
+
}
|
|
1014
|
+
`;
|
|
1015
|
+
|
|
1016
|
+
// src/components/Modal/index.tsx
|
|
1017
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1018
|
+
var Modal = ({
|
|
1019
|
+
type,
|
|
1020
|
+
title,
|
|
1021
|
+
message,
|
|
1022
|
+
primaryButtonText,
|
|
1023
|
+
onPrimaryAction,
|
|
1024
|
+
onClose,
|
|
1025
|
+
primaryButtonBgColor,
|
|
1026
|
+
primaryButtonTextColor
|
|
1027
|
+
}) => {
|
|
1028
|
+
const primaryButtonRef = useRef(null);
|
|
1029
|
+
useEffect3(() => {
|
|
1030
|
+
primaryButtonRef.current?.focus();
|
|
1031
|
+
}, []);
|
|
1032
|
+
useEffect3(() => {
|
|
1033
|
+
const handleKey = (event) => {
|
|
1034
|
+
if (event.key === "Escape") {
|
|
1035
|
+
onClose();
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
document.addEventListener("keydown", handleKey);
|
|
1039
|
+
return () => document.removeEventListener("keydown", handleKey);
|
|
1040
|
+
}, [onClose]);
|
|
1041
|
+
const handleOverlayClick = (event) => {
|
|
1042
|
+
if (event.target === event.currentTarget) {
|
|
1043
|
+
onClose();
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
return /* @__PURE__ */ jsx4(Overlay, { onClick: handleOverlayClick, role: "dialog", "aria-modal": "true", "aria-label": title, children: /* @__PURE__ */ jsxs4(Container, { $type: type, children: [
|
|
1047
|
+
/* @__PURE__ */ jsx4(CloseButton, { onClick: onClose, "aria-label": "Fechar", children: /* @__PURE__ */ jsx4(HiX2, {}) }),
|
|
1048
|
+
/* @__PURE__ */ jsx4("h2", { children: title }),
|
|
1049
|
+
/* @__PURE__ */ jsx4("p", { children: message }),
|
|
1050
|
+
/* @__PURE__ */ jsx4(
|
|
1051
|
+
PrimaryButton,
|
|
1052
|
+
{
|
|
1053
|
+
ref: primaryButtonRef,
|
|
1054
|
+
onClick: onPrimaryAction,
|
|
1055
|
+
$bgColor: primaryButtonBgColor,
|
|
1056
|
+
$textColor: primaryButtonTextColor,
|
|
1057
|
+
type: "button",
|
|
1058
|
+
children: primaryButtonText
|
|
1059
|
+
}
|
|
1060
|
+
)
|
|
1061
|
+
] }) });
|
|
1062
|
+
};
|
|
1063
|
+
|
|
811
1064
|
// src/components/PhoneInput/index.tsx
|
|
812
1065
|
import {
|
|
813
1066
|
forwardRef as forwardRef2
|
|
814
1067
|
} from "react";
|
|
815
1068
|
|
|
816
1069
|
// src/components/PhoneInput/styles.ts
|
|
817
|
-
import
|
|
1070
|
+
import styled7, { css as css6 } from "styled-components";
|
|
818
1071
|
import { PhoneInput } from "react-international-phone";
|
|
819
1072
|
import "react-international-phone/style.css";
|
|
820
|
-
var
|
|
1073
|
+
var FormLabel3 = styled7.label`
|
|
821
1074
|
font-family: ${theme.fonts.primary};
|
|
822
1075
|
font-style: normal;
|
|
823
1076
|
font-weight: 500;
|
|
@@ -827,7 +1080,7 @@ var FormLabel2 = styled5.label`
|
|
|
827
1080
|
margin-bottom: 0.5rem;
|
|
828
1081
|
text-align: left;
|
|
829
1082
|
`;
|
|
830
|
-
var StyledPhoneInput =
|
|
1083
|
+
var StyledPhoneInput = styled7(PhoneInput)`
|
|
831
1084
|
width: 100%;
|
|
832
1085
|
height: 3.125rem;
|
|
833
1086
|
background: ${(props) => props.$backgroundColor || theme.colors.white};
|
|
@@ -941,24 +1194,24 @@ var StyledPhoneInput = styled5(PhoneInput)`
|
|
|
941
1194
|
}
|
|
942
1195
|
}
|
|
943
1196
|
`;
|
|
944
|
-
var
|
|
1197
|
+
var FormErrorMessage3 = styled7.small`
|
|
945
1198
|
font-size: 0.75rem;
|
|
946
1199
|
line-height: 1.125rem;
|
|
947
1200
|
color: ${theme.colors.red};
|
|
948
1201
|
margin-top: 0.25rem;
|
|
949
1202
|
display: block;
|
|
950
1203
|
`;
|
|
951
|
-
var
|
|
1204
|
+
var FormControl3 = styled7.div.withConfig({
|
|
952
1205
|
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
953
1206
|
})`
|
|
954
|
-
${
|
|
955
|
-
${(props) => props.isInvalid &&
|
|
1207
|
+
${FormLabel3} {
|
|
1208
|
+
${(props) => props.isInvalid && css6`
|
|
956
1209
|
color: ${theme.colors.red};
|
|
957
1210
|
`};
|
|
958
1211
|
}
|
|
959
1212
|
|
|
960
1213
|
${StyledPhoneInput} {
|
|
961
|
-
${(props) => props.isInvalid &&
|
|
1214
|
+
${(props) => props.isInvalid && css6`
|
|
962
1215
|
border: 1px solid ${theme.colors.red};
|
|
963
1216
|
|
|
964
1217
|
&:not(:focus)::placeholder {
|
|
@@ -968,7 +1221,7 @@ var FormControl2 = styled5.div.withConfig({
|
|
|
968
1221
|
`};
|
|
969
1222
|
|
|
970
1223
|
.react-international-phone-input-container {
|
|
971
|
-
${(props) => props.isInvalid &&
|
|
1224
|
+
${(props) => props.isInvalid && css6`
|
|
972
1225
|
border: 1px solid ${theme.colors.red};
|
|
973
1226
|
|
|
974
1227
|
&:not(:focus)::placeholder {
|
|
@@ -979,7 +1232,7 @@ var FormControl2 = styled5.div.withConfig({
|
|
|
979
1232
|
}
|
|
980
1233
|
|
|
981
1234
|
.react-international-phone-country-selector-button {
|
|
982
|
-
${(props) => props.isInvalid &&
|
|
1235
|
+
${(props) => props.isInvalid && css6`
|
|
983
1236
|
border-right: 1px solid ${theme.colors.red};
|
|
984
1237
|
`};
|
|
985
1238
|
}
|
|
@@ -987,7 +1240,7 @@ var FormControl2 = styled5.div.withConfig({
|
|
|
987
1240
|
`;
|
|
988
1241
|
|
|
989
1242
|
// src/components/PhoneInput/index.tsx
|
|
990
|
-
import { jsx as
|
|
1243
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
991
1244
|
var PhoneInputBase = ({
|
|
992
1245
|
id,
|
|
993
1246
|
label,
|
|
@@ -1002,9 +1255,9 @@ var PhoneInputBase = ({
|
|
|
1002
1255
|
value,
|
|
1003
1256
|
...rest
|
|
1004
1257
|
}, ref) => {
|
|
1005
|
-
return /* @__PURE__ */
|
|
1006
|
-
!!label && /* @__PURE__ */
|
|
1007
|
-
/* @__PURE__ */
|
|
1258
|
+
return /* @__PURE__ */ jsxs5(FormControl3, { isInvalid: !!error, children: [
|
|
1259
|
+
!!label && /* @__PURE__ */ jsx5(FormLabel3, { htmlFor: id, $textColor: labelTextColor, children: label }),
|
|
1260
|
+
/* @__PURE__ */ jsx5(
|
|
1008
1261
|
StyledPhoneInput,
|
|
1009
1262
|
{
|
|
1010
1263
|
ref,
|
|
@@ -1038,7 +1291,7 @@ var PhoneInputBase = ({
|
|
|
1038
1291
|
$textColor: inputTextColor
|
|
1039
1292
|
}
|
|
1040
1293
|
),
|
|
1041
|
-
!!error && showErrorMessage && /* @__PURE__ */
|
|
1294
|
+
!!error && showErrorMessage && /* @__PURE__ */ jsx5(FormErrorMessage3, { "data-testid": "error-message", children: typeof error === "string" ? error : error?.message })
|
|
1042
1295
|
] });
|
|
1043
1296
|
};
|
|
1044
1297
|
var PhoneInput2 = forwardRef2(PhoneInputBase);
|
|
@@ -1047,95 +1300,7 @@ var PhoneInput2 = forwardRef2(PhoneInputBase);
|
|
|
1047
1300
|
import {
|
|
1048
1301
|
forwardRef as forwardRef3
|
|
1049
1302
|
} from "react";
|
|
1050
|
-
|
|
1051
|
-
// src/components/ProductSelect/styles.ts
|
|
1052
|
-
import styled6, { css as css5 } from "styled-components";
|
|
1053
|
-
var FormLabel3 = styled6.label`
|
|
1054
|
-
font-family: ${theme.fonts.primary};
|
|
1055
|
-
font-style: normal;
|
|
1056
|
-
font-weight: 500;
|
|
1057
|
-
font-size: 1rem;
|
|
1058
|
-
color: ${(props) => props.$textColor || theme.colors.black};
|
|
1059
|
-
display: block;
|
|
1060
|
-
margin-bottom: 0.5rem;
|
|
1061
|
-
text-align: left;
|
|
1062
|
-
`;
|
|
1063
|
-
var Select = styled6.select`
|
|
1064
|
-
font-family: ${theme.fonts.primary};
|
|
1065
|
-
font-style: normal;
|
|
1066
|
-
font-weight: 500;
|
|
1067
|
-
font-size: 1rem;
|
|
1068
|
-
line-height: 1.5rem;
|
|
1069
|
-
background: ${(props) => props.$backgroundColor || theme.colors.white};
|
|
1070
|
-
color: ${(props) => props.$textColor || theme.colors.black};
|
|
1071
|
-
padding: 0.5rem 3rem 0.5rem 0.5rem; /* Aumentado padding-right para 3rem */
|
|
1072
|
-
border-radius: 0.125rem;
|
|
1073
|
-
border: 1px solid ${(props) => props.$borderColor || theme.colors.transparent};
|
|
1074
|
-
display: block;
|
|
1075
|
-
height: 3.125rem;
|
|
1076
|
-
width: 100%;
|
|
1077
|
-
cursor: pointer;
|
|
1078
|
-
|
|
1079
|
-
/* Remover a seta padrão do navegador */
|
|
1080
|
-
-webkit-appearance: none;
|
|
1081
|
-
-moz-appearance: none;
|
|
1082
|
-
appearance: none;
|
|
1083
|
-
|
|
1084
|
-
/* Adicionar seta personalizada maior */
|
|
1085
|
-
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
|
|
1086
|
-
background-repeat: no-repeat;
|
|
1087
|
-
background-position: right 1rem center; /* Posicionado a 1rem da direita */
|
|
1088
|
-
background-size: 1.25rem; /* Tamanho da seta aumentado para 1.25rem */
|
|
1089
|
-
|
|
1090
|
-
&:focus {
|
|
1091
|
-
border-radius: 0.125rem;
|
|
1092
|
-
border: 2px solid ${(props) => props.$focusBorderColor || theme.colors.yellow500};
|
|
1093
|
-
outline: none;
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
/* Estilo para option disabled (placeholder) */
|
|
1097
|
-
option:disabled {
|
|
1098
|
-
color: ${theme.colors.gray100};
|
|
1099
|
-
font-weight: 800;
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
/* Estilo para options normais */
|
|
1103
|
-
option:not(:disabled) {
|
|
1104
|
-
color: ${(props) => props.$textColor || theme.colors.black};
|
|
1105
|
-
font-weight: 500;
|
|
1106
|
-
}
|
|
1107
|
-
`;
|
|
1108
|
-
var FormErrorMessage3 = styled6.small`
|
|
1109
|
-
font-size: 0.75rem;
|
|
1110
|
-
line-height: 1.125rem;
|
|
1111
|
-
color: ${theme.colors.red};
|
|
1112
|
-
margin-top: 0.25rem;
|
|
1113
|
-
display: block;
|
|
1114
|
-
`;
|
|
1115
|
-
var FormControl3 = styled6.div.withConfig({
|
|
1116
|
-
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
1117
|
-
})`
|
|
1118
|
-
${FormLabel3} {
|
|
1119
|
-
${(props) => props.isInvalid && css5`
|
|
1120
|
-
color: ${theme.colors.red};
|
|
1121
|
-
`};
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
${Select} {
|
|
1125
|
-
${(props) => props.isInvalid && css5`
|
|
1126
|
-
border: 1px solid ${theme.colors.red};
|
|
1127
|
-
`};
|
|
1128
|
-
|
|
1129
|
-
&:focus {
|
|
1130
|
-
${(props) => props.isInvalid && css5`
|
|
1131
|
-
border: 1px solid ${theme.colors.red};
|
|
1132
|
-
`};
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
`;
|
|
1136
|
-
|
|
1137
|
-
// src/components/ProductSelect/index.tsx
|
|
1138
|
-
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1303
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1139
1304
|
var ProductSelectBase = ({
|
|
1140
1305
|
id,
|
|
1141
1306
|
label,
|
|
@@ -1150,9 +1315,9 @@ var ProductSelectBase = ({
|
|
|
1150
1315
|
placeholder = "Selecione um produto",
|
|
1151
1316
|
...rest
|
|
1152
1317
|
}, ref) => {
|
|
1153
|
-
return /* @__PURE__ */
|
|
1154
|
-
!!label && /* @__PURE__ */
|
|
1155
|
-
/* @__PURE__ */
|
|
1318
|
+
return /* @__PURE__ */ jsxs6(FormControl, { isInvalid: !!error, children: [
|
|
1319
|
+
!!label && /* @__PURE__ */ jsx6(FormLabel, { htmlFor: id, $textColor: labelTextColor, children: label }),
|
|
1320
|
+
/* @__PURE__ */ jsxs6(
|
|
1156
1321
|
Select,
|
|
1157
1322
|
{
|
|
1158
1323
|
id,
|
|
@@ -1164,19 +1329,78 @@ var ProductSelectBase = ({
|
|
|
1164
1329
|
$textColor: textColor,
|
|
1165
1330
|
...rest,
|
|
1166
1331
|
children: [
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
products.map((product) => /* @__PURE__ */
|
|
1332
|
+
/* @__PURE__ */ jsx6("option", { value: "", disabled: true, children: placeholder }),
|
|
1333
|
+
products.map((product) => /* @__PURE__ */ jsx6("option", { value: product.id, children: product.name }, product.id))
|
|
1169
1334
|
]
|
|
1170
1335
|
}
|
|
1171
1336
|
),
|
|
1172
|
-
!!error && showErrorMessage && /* @__PURE__ */
|
|
1337
|
+
!!error && showErrorMessage && /* @__PURE__ */ jsx6(FormErrorMessage, { "data-testid": "error-message", children: typeof error === "string" ? error : error.message })
|
|
1173
1338
|
] });
|
|
1174
1339
|
};
|
|
1175
1340
|
var ProductSelect = forwardRef3(ProductSelectBase);
|
|
1176
1341
|
|
|
1342
|
+
// src/config/environments.ts
|
|
1343
|
+
var ENVIRONMENTS = {
|
|
1344
|
+
homol: {
|
|
1345
|
+
apiUrl: "https://leads-hml.mitrerealty.com.br/api-leads",
|
|
1346
|
+
apiToken: "TEFORElOR19NSVRSRTptZlFXZnhvUHdNbWVZY0FidkF0QWJ3Q2RFYWtKckJBOXg5cGNsOTBvS1V0N2ZsU0d4TEtNdEZZd3k0NFlEc0c3",
|
|
1347
|
+
whatsappPhone: "551148100601",
|
|
1348
|
+
chatUrl: "https://crm-hml.mitrerealty.com.br/wcc/UserLoginSubmit.do"
|
|
1349
|
+
},
|
|
1350
|
+
prod: {
|
|
1351
|
+
apiUrl: "https://leads.mitrerealty.com.br/api-leads",
|
|
1352
|
+
apiToken: "TEFORElOR19NSVRSRTptZlFXZnhvUHdNbWVZY0FidkF0QWJ3Q2RFYWtKckJBOXg5cGNsOTBvS1V0N2ZsU0d4TEtNdEZZd3k0NFlEc0c3",
|
|
1353
|
+
whatsappPhone: "551148100601",
|
|
1354
|
+
chatUrl: "https://crm.mitrerealty.com.br/wcc/UserLoginSubmit.do"
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
1357
|
+
var resolveEnvironment = (ambiente = "homol") => {
|
|
1358
|
+
return ENVIRONMENTS[ambiente] ?? null;
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1177
1361
|
// src/components/Form/index.tsx
|
|
1178
|
-
import { Fragment, jsx as
|
|
1362
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1179
1363
|
var phoneUtil = PhoneNumberUtil.getInstance();
|
|
1364
|
+
var PreferenciaContato = /* @__PURE__ */ ((PreferenciaContato2) => {
|
|
1365
|
+
PreferenciaContato2["Whatsapp"] = "Whatsapp";
|
|
1366
|
+
PreferenciaContato2["Email"] = "Email";
|
|
1367
|
+
PreferenciaContato2["Ligacao"] = "Liga\xE7\xE3o";
|
|
1368
|
+
return PreferenciaContato2;
|
|
1369
|
+
})(PreferenciaContato || {});
|
|
1370
|
+
var WHATSAPP_MESSAGE = "Ol\xE1! Tenho interesse e gostaria de mais informa\xE7\xF5es.";
|
|
1371
|
+
var WHATSAPP_TITLE = "Fale com um corretor por WhatsApp";
|
|
1372
|
+
var WHATSAPP_SUBTITLE = "Informe seus dados para contato.";
|
|
1373
|
+
var WHATSAPP_BUTTON_TEXT = "Entrar";
|
|
1374
|
+
var CHAT_TITLE = "Fale com um corretor por chat";
|
|
1375
|
+
var CHAT_SUBTITLE = "Informe seus dados para contato.";
|
|
1376
|
+
var CHAT_BUTTON_TEXT = "Entrar";
|
|
1377
|
+
var MODAL_ERROR_TITLE = "N\xE3o foi poss\xEDvel completar seu contato";
|
|
1378
|
+
var MODAL_ERROR_MESSAGE = "Por favor, tente novamente em alguns instantes.";
|
|
1379
|
+
var MODAL_ERROR_BUTTON_TEXT = "OK";
|
|
1380
|
+
var MODAL_SUCCESS_TITLE = "Cadastro realizado!";
|
|
1381
|
+
var MODAL_SUCCESS_MESSAGE_WHATSAPP = "Clique abaixo para continuar pelo WhatsApp.";
|
|
1382
|
+
var MODAL_SUCCESS_BUTTON_WHATSAPP = "Abrir WhatsApp";
|
|
1383
|
+
var MODAL_SUCCESS_MESSAGE_CHAT = "Clique abaixo para iniciar o atendimento.";
|
|
1384
|
+
var MODAL_SUCCESS_BUTTON_CHAT = "Iniciar atendimento";
|
|
1385
|
+
function buildWhatsappUrl(phone) {
|
|
1386
|
+
const digits = phone.replace(/\D/g, "");
|
|
1387
|
+
const text = encodeURIComponent(WHATSAPP_MESSAGE);
|
|
1388
|
+
return `https://api.whatsapp.com/send?phone=${digits}&text=${text}`;
|
|
1389
|
+
}
|
|
1390
|
+
function submitChatInNewTab(chatUrl, virtualObj) {
|
|
1391
|
+
const form = document.createElement("form");
|
|
1392
|
+
form.method = "POST";
|
|
1393
|
+
form.action = chatUrl;
|
|
1394
|
+
form.target = "_blank";
|
|
1395
|
+
const input = document.createElement("input");
|
|
1396
|
+
input.type = "hidden";
|
|
1397
|
+
input.name = "virtual_obj";
|
|
1398
|
+
input.value = JSON.stringify(virtualObj);
|
|
1399
|
+
form.appendChild(input);
|
|
1400
|
+
document.body.appendChild(form);
|
|
1401
|
+
form.submit();
|
|
1402
|
+
document.body.removeChild(form);
|
|
1403
|
+
}
|
|
1180
1404
|
var isPhoneValid = (phone) => {
|
|
1181
1405
|
try {
|
|
1182
1406
|
return phoneUtil.isValidNumber(phoneUtil.parseAndKeepRawInput(phone));
|
|
@@ -1208,8 +1432,8 @@ var schemaWithProduct = yup.object().shape({
|
|
|
1208
1432
|
var schema = yup.object().shape(baseSchema);
|
|
1209
1433
|
var MitreFormComponent = React2.forwardRef(({
|
|
1210
1434
|
products,
|
|
1211
|
-
|
|
1212
|
-
|
|
1435
|
+
ambiente = "homol",
|
|
1436
|
+
canal = "form",
|
|
1213
1437
|
showHeader = true,
|
|
1214
1438
|
title = "Atendimento por mensagem",
|
|
1215
1439
|
subtitle = "Informe seus dados e retornaremos a mensagem.",
|
|
@@ -1223,8 +1447,10 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1223
1447
|
inputFocusBorderColor = theme.colors.yellow500,
|
|
1224
1448
|
inputPlaceholderColor = theme.colors.gray100,
|
|
1225
1449
|
inputTextColor = theme.colors.black,
|
|
1226
|
-
|
|
1227
|
-
|
|
1450
|
+
showPreferenciaContato = false,
|
|
1451
|
+
idProdutoTerceiro,
|
|
1452
|
+
idEmpreendimento,
|
|
1453
|
+
naoCriarEvento
|
|
1228
1454
|
}, ref) => {
|
|
1229
1455
|
useMontserratFont();
|
|
1230
1456
|
const [loading, setIsLoading] = useState3(false);
|
|
@@ -1232,6 +1458,7 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1232
1458
|
const [successMessage, setSuccessMessage] = useState3("");
|
|
1233
1459
|
const [formKey, setFormKey] = useState3(0);
|
|
1234
1460
|
const [selectedProductId, setSelectedProductId] = useState3(null);
|
|
1461
|
+
const [actionModal, setActionModal] = useState3(null);
|
|
1235
1462
|
const validateProducts = () => {
|
|
1236
1463
|
if (!products) {
|
|
1237
1464
|
return "Lista de produtos n\xE3o foi fornecida";
|
|
@@ -1256,7 +1483,53 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1256
1483
|
}
|
|
1257
1484
|
return null;
|
|
1258
1485
|
};
|
|
1486
|
+
const env = resolveEnvironment(ambiente);
|
|
1487
|
+
const validateAmbienteConfig = () => {
|
|
1488
|
+
if (!env) {
|
|
1489
|
+
return `ambiente='${ambiente}' n\xE3o \xE9 reconhecido. Use 'homol' ou 'prod'.`;
|
|
1490
|
+
}
|
|
1491
|
+
if (!env.apiUrl || !env.apiToken) {
|
|
1492
|
+
return `Configura\xE7\xE3o interna do ambiente '${ambiente}' est\xE1 incompleta (apiUrl/apiToken).`;
|
|
1493
|
+
}
|
|
1494
|
+
return null;
|
|
1495
|
+
};
|
|
1496
|
+
const validateWhatsappConfig = () => {
|
|
1497
|
+
if (canal !== "whatsapp") return null;
|
|
1498
|
+
if (!env) return null;
|
|
1499
|
+
const raw = env.whatsappPhone?.trim() ?? "";
|
|
1500
|
+
if (!raw) {
|
|
1501
|
+
return `canal='whatsapp' exige whatsappPhone no ambiente '${ambiente}'.`;
|
|
1502
|
+
}
|
|
1503
|
+
const normalized = raw.startsWith("+") ? raw : `+${raw}`;
|
|
1504
|
+
if (!isPhoneValid(normalized)) {
|
|
1505
|
+
return `whatsappPhone do ambiente '${ambiente}' \xE9 inv\xE1lido (${JSON.stringify(env.whatsappPhone)}).`;
|
|
1506
|
+
}
|
|
1507
|
+
return null;
|
|
1508
|
+
};
|
|
1509
|
+
const validateChatConfig = () => {
|
|
1510
|
+
if (canal !== "chat") return null;
|
|
1511
|
+
if (!env) return null;
|
|
1512
|
+
const raw = env.chatUrl?.trim() ?? "";
|
|
1513
|
+
if (!raw) {
|
|
1514
|
+
return `canal='chat' exige chatUrl no ambiente '${ambiente}'.`;
|
|
1515
|
+
}
|
|
1516
|
+
try {
|
|
1517
|
+
const parsed = new URL(raw);
|
|
1518
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
1519
|
+
return `chatUrl do ambiente '${ambiente}' precisa ter protocolo http(s) (recebido: ${JSON.stringify(env.chatUrl)}).`;
|
|
1520
|
+
}
|
|
1521
|
+
} catch {
|
|
1522
|
+
return `chatUrl do ambiente '${ambiente}' n\xE3o \xE9 URL absoluta v\xE1lida (recebido: ${JSON.stringify(env.chatUrl)}).`;
|
|
1523
|
+
}
|
|
1524
|
+
return null;
|
|
1525
|
+
};
|
|
1259
1526
|
const productsValidationError = validateProducts();
|
|
1527
|
+
const ambienteConfigError = validateAmbienteConfig();
|
|
1528
|
+
const whatsappConfigError = validateWhatsappConfig();
|
|
1529
|
+
const chatConfigError = validateChatConfig();
|
|
1530
|
+
const effectiveShowPreferenciaContato = canal === "whatsapp" || canal === "chat" ? false : showPreferenciaContato;
|
|
1531
|
+
const effectiveTitle = canal === "whatsapp" ? WHATSAPP_TITLE : canal === "chat" ? CHAT_TITLE : title;
|
|
1532
|
+
const effectiveSubtitle = canal === "whatsapp" ? WHATSAPP_SUBTITLE : canal === "chat" ? CHAT_SUBTITLE : subtitle;
|
|
1260
1533
|
const [utm, setUtm] = useState3({ utm_source: "direto", createdAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
1261
1534
|
const formSchema = products && products.length > 1 ? schemaWithProduct : schema;
|
|
1262
1535
|
const { control, register, handleSubmit, formState: { errors }, reset, clearErrors } = useForm({
|
|
@@ -1291,13 +1564,17 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1291
1564
|
setFormKey((k) => k + 1);
|
|
1292
1565
|
};
|
|
1293
1566
|
const sendMessage = async (data) => {
|
|
1294
|
-
const { name, email, phone, productId } = data;
|
|
1567
|
+
const { name, email, phone, productId, preferencia_contato } = data;
|
|
1295
1568
|
const phoneValue = phone.inputValue;
|
|
1296
1569
|
const phoneDigitsOnly = phoneValue?.replace(/\D/g, "") || "";
|
|
1297
1570
|
const message = "Gostaria de mais informa\xE7\xF5es sobre o produto";
|
|
1571
|
+
setActionModal(null);
|
|
1298
1572
|
try {
|
|
1299
1573
|
setIsLoading(true);
|
|
1300
|
-
if (!
|
|
1574
|
+
if (!env) {
|
|
1575
|
+
throw new Error("Ambiente n\xE3o resolvido");
|
|
1576
|
+
}
|
|
1577
|
+
if (!products || products.length === 0) {
|
|
1301
1578
|
throw new Error("Par\xE2metros obrigat\xF3rios n\xE3o informados");
|
|
1302
1579
|
}
|
|
1303
1580
|
let selectedProduct;
|
|
@@ -1313,6 +1590,8 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1313
1590
|
}
|
|
1314
1591
|
selectedProduct = foundProduct;
|
|
1315
1592
|
}
|
|
1593
|
+
const paginaAtual = typeof window !== "undefined" ? window.location.href : void 0;
|
|
1594
|
+
const naoCriarEventoEfetivo = canal !== "form" && (naoCriarEvento ?? true);
|
|
1316
1595
|
const requestBody = {
|
|
1317
1596
|
name,
|
|
1318
1597
|
email,
|
|
@@ -1322,13 +1601,24 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1322
1601
|
utm_source: utm.utm_source,
|
|
1323
1602
|
utm_campaign: utm.utm_campaign,
|
|
1324
1603
|
utm_medium: utm.utm_medium,
|
|
1325
|
-
utm_term: utm.utm_term
|
|
1604
|
+
utm_term: utm.utm_term,
|
|
1605
|
+
...canal === "whatsapp" ? { preferencia_contato: "Whatsapp" /* Whatsapp */ } : effectiveShowPreferenciaContato && preferencia_contato ? { preferencia_contato } : {},
|
|
1606
|
+
...canal !== "form" ? {
|
|
1607
|
+
canal,
|
|
1608
|
+
...paginaAtual ? { pagina: paginaAtual } : {},
|
|
1609
|
+
// Paridade com atendimento.html legado: o mesmo <form id="chat-form">
|
|
1610
|
+
// era usado para chat e whatsapp, portanto is_chat=true ia em ambos.
|
|
1611
|
+
is_chat: true,
|
|
1612
|
+
...idProdutoTerceiro !== void 0 ? { idProdutoTerceiro } : {},
|
|
1613
|
+
...idEmpreendimento !== void 0 ? { idEmpreendimento } : {},
|
|
1614
|
+
...naoCriarEventoEfetivo ? { naoCriarEvento: true } : {}
|
|
1615
|
+
} : {}
|
|
1326
1616
|
};
|
|
1327
|
-
const response = await fetch(`${apiUrl}/leads`, {
|
|
1617
|
+
const response = await fetch(`${env.apiUrl}/leads`, {
|
|
1328
1618
|
method: "POST",
|
|
1329
1619
|
headers: {
|
|
1330
1620
|
"Content-Type": "application/json",
|
|
1331
|
-
Authorization: `Basic ${apiToken}`
|
|
1621
|
+
Authorization: `Basic ${env.apiToken}`
|
|
1332
1622
|
},
|
|
1333
1623
|
body: JSON.stringify(requestBody)
|
|
1334
1624
|
});
|
|
@@ -1337,26 +1627,61 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1337
1627
|
}
|
|
1338
1628
|
const responseData = await response.json();
|
|
1339
1629
|
const leadId = responseData.leadId || responseData.id || "";
|
|
1340
|
-
setSuccessMessage("Mensagem enviada com sucesso!");
|
|
1341
1630
|
resetForm();
|
|
1342
|
-
|
|
1631
|
+
if (canal === "whatsapp") {
|
|
1632
|
+
setActionModal({
|
|
1633
|
+
kind: "success",
|
|
1634
|
+
canal: "whatsapp",
|
|
1635
|
+
targetUrl: buildWhatsappUrl(env.whatsappPhone)
|
|
1636
|
+
});
|
|
1637
|
+
} else if (canal === "chat") {
|
|
1638
|
+
const virtualObj = {
|
|
1639
|
+
...requestBody,
|
|
1640
|
+
externalOriginId: leadId,
|
|
1641
|
+
...paginaAtual ? { pagina: paginaAtual } : {},
|
|
1642
|
+
...idProdutoTerceiro !== void 0 ? { idProdutoTerceiro } : {},
|
|
1643
|
+
...idEmpreendimento !== void 0 ? { idEmpreendimento } : {},
|
|
1644
|
+
...naoCriarEventoEfetivo ? { naoCriarEvento: true } : {}
|
|
1645
|
+
};
|
|
1646
|
+
setActionModal({
|
|
1647
|
+
kind: "success",
|
|
1648
|
+
canal: "chat",
|
|
1649
|
+
chatUrl: env.chatUrl,
|
|
1650
|
+
virtualObj
|
|
1651
|
+
});
|
|
1652
|
+
} else {
|
|
1653
|
+
setSuccessMessage("Mensagem enviada com sucesso!");
|
|
1654
|
+
}
|
|
1343
1655
|
} catch (err) {
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1656
|
+
if (canal === "whatsapp" || canal === "chat") {
|
|
1657
|
+
setActionModal({ kind: "error" });
|
|
1658
|
+
} else {
|
|
1659
|
+
handleError(err);
|
|
1660
|
+
}
|
|
1347
1661
|
} finally {
|
|
1348
1662
|
setIsLoading(false);
|
|
1349
1663
|
}
|
|
1350
1664
|
};
|
|
1351
|
-
if (productsValidationError) {
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1665
|
+
if (productsValidationError || ambienteConfigError || whatsappConfigError || chatConfigError) {
|
|
1666
|
+
if (productsValidationError) {
|
|
1667
|
+
console.error("Erro na valida\xE7\xE3o dos produtos:", productsValidationError);
|
|
1668
|
+
}
|
|
1669
|
+
if (ambienteConfigError) {
|
|
1670
|
+
console.error("Erro na valida\xE7\xE3o do ambiente:", ambienteConfigError);
|
|
1671
|
+
}
|
|
1672
|
+
if (whatsappConfigError) {
|
|
1673
|
+
console.error("Erro na valida\xE7\xE3o do canal whatsapp:", whatsappConfigError);
|
|
1674
|
+
}
|
|
1675
|
+
if (chatConfigError) {
|
|
1676
|
+
console.error("Erro na valida\xE7\xE3o do canal chat:", chatConfigError);
|
|
1677
|
+
}
|
|
1678
|
+
return /* @__PURE__ */ jsx7(FormContainer, { $backgroundColor: backgroundColor, $innerPadding: innerPadding, ref, children: /* @__PURE__ */ jsxs7(HeaderContainer, { children: [
|
|
1679
|
+
/* @__PURE__ */ jsx7(Title, { $textColor: textColor, children: "Erro no carregamento do formul\xE1rio!" }),
|
|
1680
|
+
/* @__PURE__ */ jsx7(Subtitle, { $textColor: textColor, children: "N\xE3o foi poss\xEDvel carregar o formul\xE1rio. Tente novamente mais tarde." })
|
|
1356
1681
|
] }) });
|
|
1357
1682
|
}
|
|
1358
|
-
return /* @__PURE__ */
|
|
1359
|
-
error && /* @__PURE__ */
|
|
1683
|
+
return /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
1684
|
+
error && /* @__PURE__ */ jsx7(
|
|
1360
1685
|
Alert,
|
|
1361
1686
|
{
|
|
1362
1687
|
type: "error",
|
|
@@ -1366,7 +1691,7 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1366
1691
|
children: error.message
|
|
1367
1692
|
}
|
|
1368
1693
|
),
|
|
1369
|
-
successMessage && /* @__PURE__ */
|
|
1694
|
+
successMessage && /* @__PURE__ */ jsx7(
|
|
1370
1695
|
Alert,
|
|
1371
1696
|
{
|
|
1372
1697
|
type: "success",
|
|
@@ -1376,13 +1701,58 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1376
1701
|
children: successMessage
|
|
1377
1702
|
}
|
|
1378
1703
|
),
|
|
1379
|
-
/* @__PURE__ */
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1704
|
+
actionModal?.kind === "error" && /* @__PURE__ */ jsx7(
|
|
1705
|
+
Modal,
|
|
1706
|
+
{
|
|
1707
|
+
type: "error",
|
|
1708
|
+
title: MODAL_ERROR_TITLE,
|
|
1709
|
+
message: MODAL_ERROR_MESSAGE,
|
|
1710
|
+
primaryButtonText: MODAL_ERROR_BUTTON_TEXT,
|
|
1711
|
+
onPrimaryAction: () => setActionModal(null),
|
|
1712
|
+
onClose: () => setActionModal(null),
|
|
1713
|
+
primaryButtonBgColor: buttonBackgroundColor,
|
|
1714
|
+
primaryButtonTextColor: buttonTextColor
|
|
1715
|
+
}
|
|
1716
|
+
),
|
|
1717
|
+
actionModal?.kind === "success" && actionModal.canal === "whatsapp" && /* @__PURE__ */ jsx7(
|
|
1718
|
+
Modal,
|
|
1719
|
+
{
|
|
1720
|
+
type: "success",
|
|
1721
|
+
title: MODAL_SUCCESS_TITLE,
|
|
1722
|
+
message: MODAL_SUCCESS_MESSAGE_WHATSAPP,
|
|
1723
|
+
primaryButtonText: MODAL_SUCCESS_BUTTON_WHATSAPP,
|
|
1724
|
+
onPrimaryAction: () => {
|
|
1725
|
+
window.open(actionModal.targetUrl, "_blank", "noopener,noreferrer");
|
|
1726
|
+
setActionModal(null);
|
|
1727
|
+
},
|
|
1728
|
+
onClose: () => setActionModal(null),
|
|
1729
|
+
primaryButtonBgColor: buttonBackgroundColor,
|
|
1730
|
+
primaryButtonTextColor: buttonTextColor
|
|
1731
|
+
}
|
|
1732
|
+
),
|
|
1733
|
+
actionModal?.kind === "success" && actionModal.canal === "chat" && /* @__PURE__ */ jsx7(
|
|
1734
|
+
Modal,
|
|
1735
|
+
{
|
|
1736
|
+
type: "success",
|
|
1737
|
+
title: MODAL_SUCCESS_TITLE,
|
|
1738
|
+
message: MODAL_SUCCESS_MESSAGE_CHAT,
|
|
1739
|
+
primaryButtonText: MODAL_SUCCESS_BUTTON_CHAT,
|
|
1740
|
+
onPrimaryAction: () => {
|
|
1741
|
+
submitChatInNewTab(actionModal.chatUrl, actionModal.virtualObj);
|
|
1742
|
+
setActionModal(null);
|
|
1743
|
+
},
|
|
1744
|
+
onClose: () => setActionModal(null),
|
|
1745
|
+
primaryButtonBgColor: buttonBackgroundColor,
|
|
1746
|
+
primaryButtonTextColor: buttonTextColor
|
|
1747
|
+
}
|
|
1748
|
+
),
|
|
1749
|
+
/* @__PURE__ */ jsxs7(FormContainer, { $backgroundColor: backgroundColor, $innerPadding: innerPadding, ref, children: [
|
|
1750
|
+
showHeader && /* @__PURE__ */ jsxs7(HeaderContainer, { children: [
|
|
1751
|
+
/* @__PURE__ */ jsx7(Title, { $textColor: textColor, children: effectiveTitle }),
|
|
1752
|
+
/* @__PURE__ */ jsx7(Subtitle, { $textColor: textColor, children: effectiveSubtitle })
|
|
1383
1753
|
] }),
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
products.length > 1 && /* @__PURE__ */
|
|
1754
|
+
/* @__PURE__ */ jsxs7(Form, { $textColor: textColor, onSubmit: handleSubmit(sendMessage), noValidate: true, children: [
|
|
1755
|
+
products.length > 1 && /* @__PURE__ */ jsx7(
|
|
1386
1756
|
ProductSelect,
|
|
1387
1757
|
{
|
|
1388
1758
|
id: "productId",
|
|
@@ -1399,7 +1769,7 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1399
1769
|
textColor: inputTextColor
|
|
1400
1770
|
}
|
|
1401
1771
|
),
|
|
1402
|
-
/* @__PURE__ */
|
|
1772
|
+
/* @__PURE__ */ jsx7(
|
|
1403
1773
|
Input2,
|
|
1404
1774
|
{
|
|
1405
1775
|
id: "name",
|
|
@@ -1417,7 +1787,7 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1417
1787
|
inputTextColor
|
|
1418
1788
|
}
|
|
1419
1789
|
),
|
|
1420
|
-
/* @__PURE__ */
|
|
1790
|
+
/* @__PURE__ */ jsx7(
|
|
1421
1791
|
Input2,
|
|
1422
1792
|
{
|
|
1423
1793
|
id: "email",
|
|
@@ -1436,7 +1806,7 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1436
1806
|
inputTextColor
|
|
1437
1807
|
}
|
|
1438
1808
|
),
|
|
1439
|
-
/* @__PURE__ */
|
|
1809
|
+
/* @__PURE__ */ jsx7(
|
|
1440
1810
|
Controller,
|
|
1441
1811
|
{
|
|
1442
1812
|
name: "phone",
|
|
@@ -1445,7 +1815,7 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1445
1815
|
shouldUnregister: true,
|
|
1446
1816
|
render: ({ field }) => {
|
|
1447
1817
|
const errorMsg = errors.phone?.inputValue?.message || errors.phone?.phone?.message || errors.phone?.message;
|
|
1448
|
-
return /* @__PURE__ */
|
|
1818
|
+
return /* @__PURE__ */ jsx7(
|
|
1449
1819
|
PhoneInput2,
|
|
1450
1820
|
{
|
|
1451
1821
|
id: "phone",
|
|
@@ -1468,12 +1838,32 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1468
1838
|
},
|
|
1469
1839
|
formKey
|
|
1470
1840
|
),
|
|
1471
|
-
/* @__PURE__ */
|
|
1472
|
-
|
|
1473
|
-
|
|
1841
|
+
effectiveShowPreferenciaContato && /* @__PURE__ */ jsxs7(FormControl, { isInvalid: !!errors.preferencia_contato, children: [
|
|
1842
|
+
/* @__PURE__ */ jsx7(FormLabel, { htmlFor: "preferencia_contato", $textColor: textColor, children: "Prefer\xEAncia de Contato" }),
|
|
1843
|
+
/* @__PURE__ */ jsxs7(
|
|
1844
|
+
Select,
|
|
1845
|
+
{
|
|
1846
|
+
id: "preferencia_contato",
|
|
1847
|
+
...register("preferencia_contato"),
|
|
1848
|
+
defaultValue: "",
|
|
1849
|
+
$backgroundColor: inputBackgroundColor,
|
|
1850
|
+
$borderColor: inputBorderColor,
|
|
1851
|
+
$focusBorderColor: inputFocusBorderColor,
|
|
1852
|
+
$textColor: inputTextColor,
|
|
1853
|
+
children: [
|
|
1854
|
+
/* @__PURE__ */ jsx7("option", { value: "", disabled: true, children: "Selecione uma op\xE7\xE3o" }),
|
|
1855
|
+
Object.values(PreferenciaContato).map((op) => /* @__PURE__ */ jsx7("option", { value: op, children: op }, op))
|
|
1856
|
+
]
|
|
1857
|
+
}
|
|
1858
|
+
),
|
|
1859
|
+
errors.preferencia_contato && /* @__PURE__ */ jsx7(FormErrorMessage, { children: errors.preferencia_contato.message })
|
|
1860
|
+
] }),
|
|
1861
|
+
/* @__PURE__ */ jsx7("h6", { children: "* Campos de preenchimento obrigat\xF3rio." }),
|
|
1862
|
+
/* @__PURE__ */ jsx7(ButtonContainer, { children: /* @__PURE__ */ jsx7(Button2, { bgColor: buttonBackgroundColor, color: buttonTextColor, type: "submit", isSubmitting: loading, children: canal === "whatsapp" ? WHATSAPP_BUTTON_TEXT : canal === "chat" ? CHAT_BUTTON_TEXT : "Enviar mensagem" }) }),
|
|
1863
|
+
/* @__PURE__ */ jsxs7("p", { children: [
|
|
1474
1864
|
"A Mitre Realty respeita a sua privacidade e utiliza os seus dados pessoais para contat\xE1-lo por e-mail ou telefone aqui registrados. Para saber mais, acesse a nossa",
|
|
1475
1865
|
" ",
|
|
1476
|
-
/* @__PURE__ */
|
|
1866
|
+
/* @__PURE__ */ jsx7(
|
|
1477
1867
|
"a",
|
|
1478
1868
|
{
|
|
1479
1869
|
href: "https://www.mitrerealty.com.br/politica-de-privacidade",
|
|
@@ -1495,6 +1885,7 @@ var MitreFormComponent = React2.forwardRef(({
|
|
|
1495
1885
|
MitreFormComponent.displayName = "MitreFormComponent";
|
|
1496
1886
|
var Form_default = MitreFormComponent;
|
|
1497
1887
|
export {
|
|
1498
|
-
Form_default as MitreFormComponent
|
|
1888
|
+
Form_default as MitreFormComponent,
|
|
1889
|
+
PreferenciaContato
|
|
1499
1890
|
};
|
|
1500
1891
|
//# sourceMappingURL=index.js.map
|