@gov-cy/govcy-express-services 1.3.0-alpha.4 → 1.3.0-alpha.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gov-cy/govcy-express-services",
3
- "version": "1.3.0-alpha.4",
3
+ "version": "1.3.0-alpha.5",
4
4
  "description": "An Express-based system that dynamically renders services using @gov-cy/govcy-frontend-renderer and posts data to a submission API.",
5
5
  "author": "DMRID - DSF Team",
6
6
  "license": "MIT",
@@ -162,6 +162,9 @@ export async function govcyUpdateMyDetailsHandler(req, res, next, page, serviceC
162
162
  }
163
163
  }
164
164
 
165
+ // Deep copy pageTemplate to avoid modifying the original
166
+ const pageTemplateCopy = JSON.parse(JSON.stringify(pageTemplate));
167
+
165
168
  // if the page variant is 1 or 2 which means it has a form
166
169
  if (pageVariant === 1 || pageVariant === 2) {
167
170
  // Handle form data
@@ -181,7 +184,7 @@ export async function govcyUpdateMyDetailsHandler(req, res, next, page, serviceC
181
184
 
182
185
 
183
186
  populateFormData(
184
- pageTemplate.sections[0].elements[0].params.elements,
187
+ pageTemplateCopy.sections[0].elements[0].params.elements,
185
188
  theData,
186
189
  validationErrors,
187
190
  req.session,
@@ -194,18 +197,18 @@ export async function govcyUpdateMyDetailsHandler(req, res, next, page, serviceC
194
197
 
195
198
  // if there are validation errors, add an error summary
196
199
  if (validationErrors?.errorSummary?.length > 0) {
197
- pageTemplate.sections[0].elements[0].params.elements.unshift(govcyResources.errorSummary(validationErrors.errorSummary));
200
+ pageTemplateCopy.sections[0].elements[0].params.elements.unshift(govcyResources.errorSummary(validationErrors.errorSummary));
198
201
  }
199
202
  }
200
203
 
201
204
  // Add topElements if provided
202
205
  if (Array.isArray(umdConfig.topElements)) {
203
- pageTemplate.sections[0].elements[0].params.elements.unshift(...umdConfig.topElements);
206
+ pageTemplateCopy.sections[0].elements[0].params.elements.unshift(...umdConfig.topElements);
204
207
  }
205
208
 
206
209
  //if hasBackLink == true add section beforeMain with backlink element
207
210
  if (umdConfig?.hasBackLink == true) {
208
- pageTemplate.sections.unshift({
211
+ pageTemplateCopy.sections.unshift({
209
212
  name: "beforeMain",
210
213
  elements: [
211
214
  {
@@ -226,7 +229,7 @@ export async function govcyUpdateMyDetailsHandler(req, res, next, page, serviceC
226
229
  mainLayout: page?.pageData?.mainLayout || "two-third"
227
230
  }
228
231
  },
229
- pageTemplate: pageTemplate
232
+ pageTemplate: pageTemplateCopy
230
233
  };
231
234
 
232
235
  logger.debug("Processed `govcyUpdateMyDetailsHandler` page data:", req.processedPage, req);