Skip to content

Commit

Permalink
#1291 | Fix multiple calls to POST /forms due to re-render
Browse files Browse the repository at this point in the history
#1105 (cherry picked from commit cb82855)
  • Loading branch information
1t5j0y committed Jul 24, 2024
1 parent 23983bd commit c86103c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/formDesigner/views/FormDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class FormDetails extends Component {
name: "",
timed: false,
errorMsg: "",
saveCall: false,
createFlag: true,
activeTabIndex: 0,
successAlert: false,
Expand Down Expand Up @@ -659,7 +658,7 @@ class FormDetails extends Component {
"visitScheduleRule",
"generateVisitScheduleRule"
);
flag = isValidationError || isDecisionError || isVisitScheduleError;
flag = isValidationError || isDecisionError || isVisitScheduleError || draft.nameError;
_.forEach(draft.form.formElementGroups, group => {
group.errorMessage = {};
group.error = false;
Expand Down Expand Up @@ -728,9 +727,9 @@ class FormDetails extends Component {
if (numberElementError !== 0) errormsg += " and " + numberElementError + " form element.";
} else if (numberElementError !== 0) errormsg += "There is a error in " + numberElementError + " form element.";
}
draft.saveCall = !flag;
draft.errorMsg = errormsg;
})
}),
() => flag === false && this.updateForm()
);
}

Expand Down Expand Up @@ -796,7 +795,6 @@ class FormDetails extends Component {
if (response.status === 200) {
this.setState({
redirectToWorkflow: true,
saveCall: false,
successAlert: true,
defaultSnackbarStatus: true,
detectBrowserCloseEvent: false
Expand All @@ -806,7 +804,6 @@ class FormDetails extends Component {
.then(() => this.getForm())
.catch(error => {
this.setState({
saveCall: false,
errorMsg: "Server error received " + error.response.data
});
});
Expand Down Expand Up @@ -1017,7 +1014,6 @@ class FormDetails extends Component {
defaultSnackbarStatus={this.state.defaultSnackbarStatus}
/>
)}
{this.state.saveCall && !this.state.nameError && this.updateForm()}
</Box>
</FormDesignerContext.Provider>
);
Expand Down

0 comments on commit c86103c

Please sign in to comment.