diy-template-components 2.0.17 → 2.0.19

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/build/index.js CHANGED
@@ -6906,6 +6906,7 @@ function FormEnquiry({
6906
6906
  isMobile
6907
6907
  });
6908
6908
  const [nodeData] = sectionData.components;
6909
+ const [isSubmitted, setIsSubmitted] = React.useState(false);
6909
6910
  const theme = useTheme();
6910
6911
  let [btnDisabled, setBtnDisabled] = React.useState(false);
6911
6912
  let formInitialValue = {
@@ -6922,12 +6923,12 @@ function FormEnquiry({
6922
6923
  messageValid: 1
6923
6924
  });
6924
6925
  React.useEffect(() => {
6925
- if (validData?.nameValid && validData?.emailValid && validData?.phoneValid && validData?.messageValid) {
6926
+ if (validData?.nameValid && validData?.emailValid && validData?.phoneValid && validData?.messageValid && inputVal?.email && inputVal?.name && inputVal?.phone && inputVal?.message) {
6926
6927
  setBtnDisabled(false);
6927
6928
  } else {
6928
6929
  setBtnDisabled(true);
6929
6930
  }
6930
- }, [validData]);
6931
+ }, [validData, inputVal]);
6931
6932
  const handleSubmit = () => {
6932
6933
  let data = {
6933
6934
  sectionId: sectionData?._id || null,
@@ -6942,6 +6943,10 @@ function FormEnquiry({
6942
6943
  if (!(isPreview || isEdit)) postApiCall(baseURLs, data);
6943
6944
  setBtnDisabled(true);
6944
6945
  setInputVal(formInitialValue);
6946
+ setIsSubmitted(true);
6947
+ setTimeout(() => {
6948
+ setIsSubmitted(false);
6949
+ }, 1000);
6945
6950
  };
6946
6951
  const checkValidity = (regexField, fieldname, fieldValidity) => {
6947
6952
  if (validations?.[regexField]?.length) {
@@ -7122,7 +7127,7 @@ function FormEnquiry({
7122
7127
  className: classes.btnContainer
7123
7128
  }, /*#__PURE__*/React__default["default"].createElement(Button, {
7124
7129
  ref: nodeData?.cta?.refSetter,
7125
- data: btnDisabled && validData?.messageValid && validData?.emailValid && validData?.nameValid && validData?.phoneValid ? {
7130
+ data: isSubmitted ? {
7126
7131
  value: 'Submitted'
7127
7132
  } : {
7128
7133
  value: nodeData.cta.metadata.value