mitre-form-component 0.0.34 → 0.0.36
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 +5 -1
- package/dist/index.cjs +273 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +272 -146
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -50,6 +50,8 @@ import { MitreFormComponent } from "mitre-form-component-next";
|
|
|
50
50
|
showHeader={true} // opcional
|
|
51
51
|
colorPrimary="#FF5733" // opcional
|
|
52
52
|
textColor="#ffffff" // opcional
|
|
53
|
+
backgroundColor="#000" // opcional
|
|
54
|
+
innerPadding="0.2rem" // opcional
|
|
53
55
|
/>;
|
|
54
56
|
```
|
|
55
57
|
|
|
@@ -63,7 +65,7 @@ import { MitreFormComponent } from "mitre-form-component-next";
|
|
|
63
65
|
- [Styled Components](https://styled-components.com/)
|
|
64
66
|
- [Polished](https://polished.js.org/)
|
|
65
67
|
- [React Icons](https://react-icons.github.io/react-icons/)
|
|
66
|
-
- [React Phone
|
|
68
|
+
- [React Internation Phone](https://github.com/ybrusentsov/react-international-phone)
|
|
67
69
|
- [Vite](https://vitejs.dev/)
|
|
68
70
|
- [Tsup](https://tsup.egoist.dev/)
|
|
69
71
|
|
|
@@ -102,6 +104,8 @@ O `MitreFormComponent` aceita as seguintes props:
|
|
|
102
104
|
- **`showHeader`** (opcional, boolean): Controla se o cabeçalho será mostrado. Padrão: `false`.
|
|
103
105
|
- **`colorPrimary`** (opcional, string): Cor primária do componente. Exemplo: `#FF5733`.
|
|
104
106
|
- **`textColor`** (opcional, string): Cor do texto do componente. Exemplo: `#ffffff`.
|
|
107
|
+
- **`backgroundColor`** (opcional, string): Cor do fundo do componente. Exemplo: `#CECECE`.
|
|
108
|
+
- **`innerPadding`** (opcional, string): Espaçamento interno do componente. Exemplo: `1rem`.
|
|
105
109
|
|
|
106
110
|
---
|
|
107
111
|
|
package/dist/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// src/components/Form/index.tsx
|
|
38
|
-
var
|
|
38
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
39
39
|
|
|
40
40
|
// src/components/hooks/useError.ts
|
|
41
41
|
var import_react = require("react");
|
|
@@ -54,6 +54,7 @@ function useError() {
|
|
|
54
54
|
var import_react_hook_form = require("react-hook-form");
|
|
55
55
|
var import_yup = require("@hookform/resolvers/yup");
|
|
56
56
|
var yup = __toESM(require("yup"), 1);
|
|
57
|
+
var import_google_libphonenumber = require("google-libphonenumber");
|
|
57
58
|
|
|
58
59
|
// src/components/styles/utils.ts
|
|
59
60
|
function flex(direction = "row", alignItems, justifyContent) {
|
|
@@ -377,14 +378,12 @@ function date(e) {
|
|
|
377
378
|
|
|
378
379
|
// src/components/Input/styles.ts
|
|
379
380
|
var import_styled_components3 = __toESM(require("styled-components"), 1);
|
|
380
|
-
var import_react_international_phone = require("react-international-phone");
|
|
381
|
-
var import_style = require("react-international-phone/style.css");
|
|
382
381
|
var FormLabel = import_styled_components3.default.label`
|
|
383
382
|
font-family: "Montserrat", sans-serif;
|
|
384
383
|
font-style: normal;
|
|
385
384
|
font-weight: 500;
|
|
386
385
|
font-size: 1rem;
|
|
387
|
-
color: ${(props) => props
|
|
386
|
+
color: ${(props) => props.$textColor || "var(--black)"};
|
|
388
387
|
display: block;
|
|
389
388
|
margin-bottom: 0.5rem;
|
|
390
389
|
text-align: left;
|
|
@@ -439,7 +438,7 @@ var FormErrorMessage = import_styled_components3.default.small`
|
|
|
439
438
|
display: block;
|
|
440
439
|
`;
|
|
441
440
|
var FormControl = import_styled_components3.default.div.withConfig({
|
|
442
|
-
shouldForwardProp: (prop) => !["isInvalid"
|
|
441
|
+
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
443
442
|
})`
|
|
444
443
|
${FormLabel} {
|
|
445
444
|
${(props) => props.isInvalid && import_styled_components3.css`
|
|
@@ -464,74 +463,6 @@ var FormControl = import_styled_components3.default.div.withConfig({
|
|
|
464
463
|
}
|
|
465
464
|
}
|
|
466
465
|
`;
|
|
467
|
-
var StyledPhoneInput = (0, import_styled_components3.default)(import_react_international_phone.PhoneInput)`
|
|
468
|
-
width: 100%;
|
|
469
|
-
height: 3.125rem;
|
|
470
|
-
|
|
471
|
-
&:focus-within {
|
|
472
|
-
border: 2px solid ${(props) => props.$bordercolor || "var(--yellow-500)"};
|
|
473
|
-
border-radius: 0.5rem;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
.react-international-phone-input-container {
|
|
477
|
-
width: 100%;
|
|
478
|
-
height: 100%;
|
|
479
|
-
border: 1px solid transparent;
|
|
480
|
-
display: flex;
|
|
481
|
-
align-items: center;
|
|
482
|
-
overflow: hidden;
|
|
483
|
-
font-family: "Montserrat", sans-serif;
|
|
484
|
-
font-size: 1rem;
|
|
485
|
-
font-weight: 500;
|
|
486
|
-
color: var(--black);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
.react-international-phone-country-selector-button {
|
|
490
|
-
height: 100%;
|
|
491
|
-
background: var(--gray-500);
|
|
492
|
-
display: flex;
|
|
493
|
-
align-items: center;
|
|
494
|
-
justify-content: center;
|
|
495
|
-
font-family: "Montserrat", sans-serif;
|
|
496
|
-
font-size: 1rem;
|
|
497
|
-
font-weight: 500;
|
|
498
|
-
cursor: pointer;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
input.react-international-phone-input {
|
|
502
|
-
flex: 1;
|
|
503
|
-
height: 100%;
|
|
504
|
-
padding: 0 0.5rem;
|
|
505
|
-
margin: 0;
|
|
506
|
-
background: var(--gray-500);
|
|
507
|
-
font-family: "Montserrat", sans-serif;
|
|
508
|
-
font-style: normal;
|
|
509
|
-
font-weight: 500;
|
|
510
|
-
font-size: 1rem;
|
|
511
|
-
line-height: 1.5rem;
|
|
512
|
-
color: var(--black);
|
|
513
|
-
outline: none;
|
|
514
|
-
|
|
515
|
-
&::placeholder {
|
|
516
|
-
font-size: 1rem;
|
|
517
|
-
line-height: 1.5rem;
|
|
518
|
-
color: #b6b6b6;
|
|
519
|
-
font-weight: 800;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
&:-webkit-autofill {
|
|
523
|
-
background: var(--gray-500) !important;
|
|
524
|
-
-webkit-text-fill-color: var(--black) !important;
|
|
525
|
-
transition: background-color 5000s ease-in-out 0s;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
&:-webkit-autofill::first-line {
|
|
529
|
-
font-family: "Montserrat", sans-serif;
|
|
530
|
-
font-size: 1rem;
|
|
531
|
-
font-weight: 500;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
`;
|
|
535
466
|
|
|
536
467
|
// src/components/Input/index.tsx
|
|
537
468
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -558,34 +489,6 @@ var InputBase = ({ id, label, error, showErrorMessage = true, borderColor, textC
|
|
|
558
489
|
autoComplete: rest.autoComplete || "on",
|
|
559
490
|
...rest
|
|
560
491
|
}
|
|
561
|
-
) : mask === "phone" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
562
|
-
StyledPhoneInput,
|
|
563
|
-
{
|
|
564
|
-
defaultCountry: "br",
|
|
565
|
-
disableCountryGuess: true,
|
|
566
|
-
disableDialCodeAndPrefix: true,
|
|
567
|
-
$bordercolor: borderColor,
|
|
568
|
-
placeholder: rest.placeholder,
|
|
569
|
-
"aria-invalid": !!error && showErrorMessage ? "true" : "false",
|
|
570
|
-
onChange: (value) => {
|
|
571
|
-
if (typeof rest.onChange === "function") {
|
|
572
|
-
const event = {
|
|
573
|
-
target: {
|
|
574
|
-
name: rest.name,
|
|
575
|
-
value
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
rest.onChange(event);
|
|
579
|
-
}
|
|
580
|
-
},
|
|
581
|
-
inputProps: {
|
|
582
|
-
id,
|
|
583
|
-
name: "phone",
|
|
584
|
-
required: true,
|
|
585
|
-
autoFocus: true,
|
|
586
|
-
autoComplete: "tel"
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
492
|
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
590
493
|
Input,
|
|
591
494
|
{
|
|
@@ -891,21 +794,209 @@ var Alert = ({
|
|
|
891
794
|
);
|
|
892
795
|
};
|
|
893
796
|
|
|
894
|
-
// src/components/
|
|
797
|
+
// src/components/PhoneInput/index.tsx
|
|
798
|
+
var import_react5 = require("react");
|
|
799
|
+
|
|
800
|
+
// src/components/PhoneInput/styles.ts
|
|
801
|
+
var import_styled_components6 = __toESM(require("styled-components"), 1);
|
|
802
|
+
var import_react_international_phone = require("react-international-phone");
|
|
803
|
+
var import_style = require("react-international-phone/style.css");
|
|
804
|
+
var FormLabel2 = import_styled_components6.default.label`
|
|
805
|
+
font-family: "Montserrat", sans-serif;
|
|
806
|
+
font-style: normal;
|
|
807
|
+
font-weight: 500;
|
|
808
|
+
font-size: 1rem;
|
|
809
|
+
color: ${(props) => props.$textColor || "var(--black)"};
|
|
810
|
+
display: block;
|
|
811
|
+
margin-bottom: 0.5rem;
|
|
812
|
+
text-align: left;
|
|
813
|
+
`;
|
|
814
|
+
var StyledPhoneInput = (0, import_styled_components6.default)(import_react_international_phone.PhoneInput)`
|
|
815
|
+
width: 100%;
|
|
816
|
+
height: 3.125rem;
|
|
817
|
+
background: var(--gray-500);
|
|
818
|
+
font-family: "Montserrat", sans-serif;
|
|
819
|
+
|
|
820
|
+
&:focus-within {
|
|
821
|
+
border-radius: 0.125rem;
|
|
822
|
+
border: 2px solid ${(props) => props.$bordercolor || "var(--yellow-500)"};
|
|
823
|
+
outline: none;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/* Style for the inner phone input container */
|
|
827
|
+
.react-international-phone-input-container {
|
|
828
|
+
width: 100%;
|
|
829
|
+
height: 100%;
|
|
830
|
+
display: flex;
|
|
831
|
+
align-items: center;
|
|
832
|
+
overflow: hidden;
|
|
833
|
+
font-family: "Montserrat", sans-serif;
|
|
834
|
+
font-size: 1rem;
|
|
835
|
+
font-weight: 500;
|
|
836
|
+
color: var(--black);
|
|
837
|
+
background: var(--white);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/* Style for the country selector button */
|
|
841
|
+
.react-international-phone-country-selector-button {
|
|
842
|
+
height: 100%;
|
|
843
|
+
background: var(--white);
|
|
844
|
+
display: flex;
|
|
845
|
+
align-items: center;
|
|
846
|
+
justify-content: center;
|
|
847
|
+
font-family: "Montserrat", sans-serif;
|
|
848
|
+
font-size: 1rem;
|
|
849
|
+
font-weight: 500;
|
|
850
|
+
cursor: pointer;
|
|
851
|
+
outline: none;
|
|
852
|
+
border: none;
|
|
853
|
+
border-right: 2px solid var(--gray-300);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/* Style for the input itself */
|
|
857
|
+
input.react-international-phone-input {
|
|
858
|
+
flex: 1;
|
|
859
|
+
height: 100%;
|
|
860
|
+
padding: 0 0.5rem;
|
|
861
|
+
margin: 0;
|
|
862
|
+
background: var(--white);
|
|
863
|
+
font-family: "Montserrat", sans-serif;
|
|
864
|
+
font-style: normal;
|
|
865
|
+
font-weight: 500;
|
|
866
|
+
font-size: 1rem;
|
|
867
|
+
line-height: 1.5rem;
|
|
868
|
+
color: var(--black);
|
|
869
|
+
outline: none;
|
|
870
|
+
border: none;
|
|
871
|
+
border-radius: 0.125rem;
|
|
872
|
+
|
|
873
|
+
&::placeholder {
|
|
874
|
+
font-size: 1rem;
|
|
875
|
+
line-height: 1.5rem;
|
|
876
|
+
color: #b6b6b6;
|
|
877
|
+
font-weight: 800;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
&:-webkit-autofill {
|
|
881
|
+
background: var(--gray-500) !important;
|
|
882
|
+
-webkit-text-fill-color: var(--black) !important;
|
|
883
|
+
transition: background-color 5000s ease-in-out 0s;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
&:-webkit-autofill::first-line {
|
|
887
|
+
font-family: "Montserrat", sans-serif;
|
|
888
|
+
font-size: 1rem;
|
|
889
|
+
font-weight: 500;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
`;
|
|
893
|
+
var FormErrorMessage2 = import_styled_components6.default.small`
|
|
894
|
+
font-size: 0.75rem;
|
|
895
|
+
line-height: 1.125rem;
|
|
896
|
+
color: var(--red);
|
|
897
|
+
margin-top: 0.25rem;
|
|
898
|
+
display: block;
|
|
899
|
+
`;
|
|
900
|
+
var FormControl2 = import_styled_components6.default.div.withConfig({
|
|
901
|
+
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
902
|
+
})`
|
|
903
|
+
${FormLabel2} {
|
|
904
|
+
${(props) => props.isInvalid && import_styled_components6.css`
|
|
905
|
+
color: var(--red);
|
|
906
|
+
`};
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
${StyledPhoneInput} {
|
|
910
|
+
${(props) => props.isInvalid && import_styled_components6.css`
|
|
911
|
+
border: 1px solid var(--red);
|
|
912
|
+
|
|
913
|
+
&:not(:focus)::placeholder {
|
|
914
|
+
color: var(--red);
|
|
915
|
+
font-weight: 600;
|
|
916
|
+
}
|
|
917
|
+
`};
|
|
918
|
+
|
|
919
|
+
.react-international-phone-input-container {
|
|
920
|
+
${(props) => props.isInvalid && import_styled_components6.css`
|
|
921
|
+
border: 1px solid var(--red);
|
|
922
|
+
|
|
923
|
+
&:not(:focus)::placeholder {
|
|
924
|
+
color: var(--red);
|
|
925
|
+
font-weight: 600;
|
|
926
|
+
}
|
|
927
|
+
`};
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
`;
|
|
931
|
+
|
|
932
|
+
// src/components/PhoneInput/index.tsx
|
|
895
933
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
934
|
+
var PhoneInputBase = ({ id, label, error, showErrorMessage = true, borderColor, textColor, value, ...rest }, ref) => {
|
|
935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(FormControl2, { isInvalid: !!error, children: [
|
|
936
|
+
!!label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FormLabel2, { htmlFor: id, $textColor: textColor, children: label }),
|
|
937
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
938
|
+
StyledPhoneInput,
|
|
939
|
+
{
|
|
940
|
+
ref,
|
|
941
|
+
defaultCountry: "br",
|
|
942
|
+
disableCountryGuess: true,
|
|
943
|
+
disableDialCodeAndPrefix: true,
|
|
944
|
+
showDisabledDialCodeAndPrefix: false,
|
|
945
|
+
$bordercolor: borderColor,
|
|
946
|
+
placeholder: rest.placeholder,
|
|
947
|
+
"aria-invalid": !!error && showErrorMessage ? "true" : "false",
|
|
948
|
+
value: String(value),
|
|
949
|
+
onChange: (phone, meta) => {
|
|
950
|
+
if (typeof rest.onChange === "function") {
|
|
951
|
+
rest.onChange({
|
|
952
|
+
phone,
|
|
953
|
+
dialCode: meta.country.dialCode,
|
|
954
|
+
inputValue: meta.inputValue
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
},
|
|
958
|
+
inputProps: {
|
|
959
|
+
id,
|
|
960
|
+
name: rest.name || "phone",
|
|
961
|
+
required: rest.required,
|
|
962
|
+
autoFocus: rest.autoFocus,
|
|
963
|
+
autoComplete: rest.autoComplete || "tel"
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
),
|
|
967
|
+
!!error && showErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FormErrorMessage2, { "data-testid": "error-message", children: typeof error === "string" ? error : error?.message })
|
|
968
|
+
] });
|
|
969
|
+
};
|
|
970
|
+
var PhoneInput2 = (0, import_react5.forwardRef)(PhoneInputBase);
|
|
971
|
+
|
|
972
|
+
// src/components/Form/index.tsx
|
|
973
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
974
|
+
var phoneUtil = import_google_libphonenumber.PhoneNumberUtil.getInstance();
|
|
975
|
+
var isPhoneValid = (phone) => {
|
|
976
|
+
try {
|
|
977
|
+
return phoneUtil.isValidNumber(phoneUtil.parseAndKeepRawInput(phone));
|
|
978
|
+
} catch (error) {
|
|
979
|
+
console.log("erro ao validar telefone = " + error);
|
|
980
|
+
return false;
|
|
981
|
+
}
|
|
982
|
+
};
|
|
896
983
|
var schema = yup.object().shape({
|
|
897
984
|
name: yup.string().required("Nome \xE9 obrigat\xF3rio"),
|
|
898
985
|
email: yup.string().required("Email \xE9 obrigat\xF3rio").email("Email inv\xE1lido"),
|
|
899
|
-
phone: yup.
|
|
900
|
-
"
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
986
|
+
phone: yup.object().shape({
|
|
987
|
+
phone: yup.string().required("Telefone \xE9 obrigat\xF3rio!").test(
|
|
988
|
+
"is-valid-phone",
|
|
989
|
+
"N\xFAmero de telefone inv\xE1lido!",
|
|
990
|
+
function(value) {
|
|
991
|
+
const digitsOnly = value?.replace(/\D/g, "") || "";
|
|
992
|
+
return digitsOnly.length >= 8 && isPhoneValid(value);
|
|
993
|
+
}
|
|
994
|
+
),
|
|
995
|
+
inputValue: yup.string().required("Telefone \xE9 obrigat\xF3rio!"),
|
|
996
|
+
dialCode: yup.string().required("C\xF3digo de pa\xEDs \xE9 obrigat\xF3rio")
|
|
997
|
+
})
|
|
907
998
|
});
|
|
908
|
-
var MitreFormComponent =
|
|
999
|
+
var MitreFormComponent = import_react6.default.forwardRef(({
|
|
909
1000
|
productId,
|
|
910
1001
|
apiUrl,
|
|
911
1002
|
apiToken,
|
|
@@ -916,18 +1007,38 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
916
1007
|
showHeader = true,
|
|
917
1008
|
colorPrimary = "#F6C76B",
|
|
918
1009
|
textColor = "#2F2F2F",
|
|
919
|
-
backgroundColor = "#
|
|
1010
|
+
backgroundColor = "#CECECE",
|
|
920
1011
|
innerPadding = "1rem"
|
|
921
1012
|
}, ref) => {
|
|
922
|
-
const [loading, setIsLoading] = (0,
|
|
1013
|
+
const [loading, setIsLoading] = (0, import_react6.useState)(false);
|
|
923
1014
|
const { error, handleError, clearError } = useError();
|
|
924
|
-
const [successMessage, setSuccessMessage] = (0,
|
|
925
|
-
const
|
|
926
|
-
|
|
1015
|
+
const [successMessage, setSuccessMessage] = (0, import_react6.useState)("");
|
|
1016
|
+
const [formKey, setFormKey] = (0, import_react6.useState)(0);
|
|
1017
|
+
const { control, register, handleSubmit, formState: { errors }, reset, clearErrors } = (0, import_react_hook_form.useForm)({
|
|
1018
|
+
resolver: (0, import_yup.yupResolver)(schema),
|
|
1019
|
+
mode: "onSubmit"
|
|
927
1020
|
});
|
|
928
|
-
const
|
|
1021
|
+
const resetForm = () => {
|
|
1022
|
+
reset({
|
|
1023
|
+
name: "",
|
|
1024
|
+
email: "",
|
|
1025
|
+
phone: { phone: "", inputValue: "", dialCode: "" }
|
|
1026
|
+
}, {
|
|
1027
|
+
keepErrors: false,
|
|
1028
|
+
keepDirty: false,
|
|
1029
|
+
keepTouched: false,
|
|
1030
|
+
keepIsSubmitted: false,
|
|
1031
|
+
keepSubmitCount: false,
|
|
1032
|
+
keepValues: false,
|
|
1033
|
+
keepDefaultValues: false
|
|
1034
|
+
});
|
|
1035
|
+
clearErrors();
|
|
1036
|
+
setFormKey((k) => k + 1);
|
|
1037
|
+
};
|
|
929
1038
|
const sendMessage = async (data) => {
|
|
930
1039
|
const { name, email, phone } = data;
|
|
1040
|
+
const phoneValue = phone.inputValue;
|
|
1041
|
+
const phoneDigitsOnly = phoneValue?.replace(/\D/g, "") || "";
|
|
931
1042
|
const message = "Gostaria de mais informa\xE7\xF5es sobre o produto";
|
|
932
1043
|
try {
|
|
933
1044
|
setIsLoading(true);
|
|
@@ -943,7 +1054,7 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
943
1054
|
body: JSON.stringify({
|
|
944
1055
|
name,
|
|
945
1056
|
email,
|
|
946
|
-
phone,
|
|
1057
|
+
phone: phoneDigitsOnly,
|
|
947
1058
|
message,
|
|
948
1059
|
productId,
|
|
949
1060
|
utm_source,
|
|
@@ -953,24 +1064,21 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
953
1064
|
})
|
|
954
1065
|
});
|
|
955
1066
|
if (!response.ok) {
|
|
1067
|
+
console.log("response = " + JSON.stringify(response));
|
|
956
1068
|
throw new Error("Falha ao enviar a mensagem!");
|
|
957
1069
|
}
|
|
958
1070
|
setSuccessMessage("Mensagem enviada com sucesso!");
|
|
959
|
-
|
|
960
|
-
name: "",
|
|
961
|
-
email: "",
|
|
962
|
-
phone: ""
|
|
963
|
-
});
|
|
1071
|
+
resetForm();
|
|
964
1072
|
} catch (err) {
|
|
965
1073
|
handleError(err);
|
|
966
1074
|
} finally {
|
|
967
1075
|
setIsLoading(false);
|
|
968
1076
|
}
|
|
969
1077
|
};
|
|
970
|
-
return /* @__PURE__ */ (0,
|
|
971
|
-
/* @__PURE__ */ (0,
|
|
972
|
-
/* @__PURE__ */ (0,
|
|
973
|
-
error && /* @__PURE__ */ (0,
|
|
1078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1079
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(global_default, {}),
|
|
1080
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GlobalStyles, {}),
|
|
1081
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
974
1082
|
Alert,
|
|
975
1083
|
{
|
|
976
1084
|
type: "error",
|
|
@@ -980,7 +1088,7 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
980
1088
|
children: error.message
|
|
981
1089
|
}
|
|
982
1090
|
),
|
|
983
|
-
successMessage && /* @__PURE__ */ (0,
|
|
1091
|
+
successMessage && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
984
1092
|
Alert,
|
|
985
1093
|
{
|
|
986
1094
|
type: "success",
|
|
@@ -990,13 +1098,13 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
990
1098
|
children: successMessage
|
|
991
1099
|
}
|
|
992
1100
|
),
|
|
993
|
-
/* @__PURE__ */ (0,
|
|
994
|
-
showHeader && /* @__PURE__ */ (0,
|
|
995
|
-
/* @__PURE__ */ (0,
|
|
996
|
-
/* @__PURE__ */ (0,
|
|
1101
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(FormContainer, { $backgroundColor: backgroundColor, $innerPadding: innerPadding, ref, children: [
|
|
1102
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(HeaderContainer, { children: [
|
|
1103
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Title, { $textColor: textColor, children: "Atendimento por mensagem" }),
|
|
1104
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { $textColor: textColor, children: "Informe seus dados e retornaremos a mensagem." })
|
|
997
1105
|
] }),
|
|
998
|
-
/* @__PURE__ */ (0,
|
|
999
|
-
/* @__PURE__ */ (0,
|
|
1106
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Form, { $textColor: textColor, onSubmit: handleSubmit(sendMessage), noValidate: true, children: [
|
|
1107
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1000
1108
|
Input2,
|
|
1001
1109
|
{
|
|
1002
1110
|
id: "name",
|
|
@@ -1010,7 +1118,7 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
1010
1118
|
required: true
|
|
1011
1119
|
}
|
|
1012
1120
|
),
|
|
1013
|
-
/* @__PURE__ */ (0,
|
|
1121
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1014
1122
|
Input2,
|
|
1015
1123
|
{
|
|
1016
1124
|
id: "email",
|
|
@@ -1025,24 +1133,40 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
1025
1133
|
required: true
|
|
1026
1134
|
}
|
|
1027
1135
|
),
|
|
1028
|
-
/* @__PURE__ */ (0,
|
|
1029
|
-
|
|
1136
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1137
|
+
import_react_hook_form.Controller,
|
|
1030
1138
|
{
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1139
|
+
name: "phone",
|
|
1140
|
+
control,
|
|
1141
|
+
defaultValue: { phone: "", inputValue: "", dialCode: "" },
|
|
1142
|
+
shouldUnregister: true,
|
|
1143
|
+
render: ({ field }) => {
|
|
1144
|
+
const errorMsg = errors.phone?.inputValue?.message || errors.phone?.phone?.message || errors.phone?.message;
|
|
1145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1146
|
+
PhoneInput2,
|
|
1147
|
+
{
|
|
1148
|
+
id: "phone",
|
|
1149
|
+
label: "Telefone *",
|
|
1150
|
+
placeholder: "(11) 00000-0000",
|
|
1151
|
+
borderColor: colorPrimary,
|
|
1152
|
+
textColor,
|
|
1153
|
+
error: errorMsg,
|
|
1154
|
+
required: true,
|
|
1155
|
+
value: field.value.phone,
|
|
1156
|
+
onChange: field.onChange,
|
|
1157
|
+
name: field.name
|
|
1158
|
+
}
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
},
|
|
1162
|
+
formKey
|
|
1039
1163
|
),
|
|
1040
|
-
/* @__PURE__ */ (0,
|
|
1041
|
-
/* @__PURE__ */ (0,
|
|
1042
|
-
/* @__PURE__ */ (0,
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h6", { children: "* Campos de preenchimento obrigat\xF3rio." }),
|
|
1165
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ButtonContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Button2, { bgColor: colorPrimary, color: textColor, type: "submit", isSubmitting: loading, children: "Enviar mensagem" }) }),
|
|
1166
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { children: [
|
|
1043
1167
|
"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",
|
|
1044
1168
|
" ",
|
|
1045
|
-
/* @__PURE__ */ (0,
|
|
1169
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1046
1170
|
"a",
|
|
1047
1171
|
{
|
|
1048
1172
|
href: "https://www.mitrerealty.com.br/politica-de-privacidade",
|