Skip to content

Commit

Permalink
Merge pull request #370 from HDRUK/HotFixCloning
Browse files Browse the repository at this point in the history
Fixed submission of empty forms
  • Loading branch information
PaulMcCaffertyPA authored May 12, 2021
2 parents 7c90f13 + deeccd4 commit c702fad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/resources/datarequest/utils/datarequest.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const cloneIntoExistingApplication = (appToClone, appToUpdate) => {
const { jsonSchema: schemaToUpdate } = appToUpdate;

// 2. Extract and append any user repeated sections from the original form
if (containsUserRepeatedSections(questionAnswers)) {
if (questionAnswers && Object.keys(questionAnswers).length > 0 && containsUserRepeatedSections(questionAnswers)) {
const updatedSchema = copyUserRepeatedSections(appToClone, schemaToUpdate);
appToUpdate.jsonSchema = updatedSchema;
}
Expand Down Expand Up @@ -249,7 +249,7 @@ const cloneIntoNewApplication = async (appToClone, context) => {
};

// 4. Extract and append any user repeated sections from the original form
if (containsUserRepeatedSections(questionAnswers)) {
if (questionAnswers && Object.keys(questionAnswers).length > 0 && containsUserRepeatedSections(questionAnswers)) {
const updatedSchema = copyUserRepeatedSections(appToClone, jsonSchema);
newApplication.jsonSchema = updatedSchema;
}
Expand Down

0 comments on commit c702fad

Please sign in to comment.