@ukhomeoffice/cop-react-form-renderer 3.2.2 → 3.2.3

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.
@@ -246,27 +246,6 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
246
246
  var onPageAction = function onPageAction(action, patch) {
247
247
  // Check to see whether the action is able to proceed, which in
248
248
  // in the case of a submission will validate the fields in the page.
249
- if (action.type === _models.PageAction.TYPES.SUBMIT) {
250
- if (_helpers.default.canCYASubmit(pages, validate.pages)) {
251
- // Submit.
252
- var submissionData = _utils.default.Format.form({
253
- pages: pages,
254
- components: components
255
- }, _objectSpread({}, data), _models.EventTypes.SUBMIT);
256
-
257
- submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
258
- setData(submissionData); // Now submit the data to the backend...
259
-
260
- hooks.onSubmit(action.type, submissionData, function () {
261
- return hooks.onFormComplete();
262
- }, function (errors) {
263
- return _handlers.default.submissionError(errors, addErrors);
264
- });
265
- }
266
- } // Check to see whether the action is able to proceed, which in
267
- // in the case of a submission will validate the fields in the page.
268
-
269
-
270
249
  if (_helpers.default.canActionProceed(action, formState.page, validate.page)) {
271
250
  patch = _helpers.default.cleanHiddenNestedData(patch, formState.page);
272
251
 
@@ -274,15 +253,15 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
274
253
  _handlers.default.navigate(action, pageId, onPageChange);
275
254
  } else {
276
255
  // Save draft or submit.
277
- var _submissionData = _utils.default.Format.form({
256
+ var submissionData = _utils.default.Format.form({
278
257
  pages: pages,
279
258
  components: components
280
259
  }, _objectSpread(_objectSpread({}, data), patch), _models.EventTypes.SUBMIT);
281
260
 
282
- _submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData, currentTask, true);
261
+ submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
283
262
 
284
263
  if (patch) {
285
- setData(_submissionData);
264
+ setData(submissionData);
286
265
  }
287
266
 
288
267
  var pageUpdate = function pageUpdate(next) {
@@ -298,10 +277,10 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
298
277
  } // Now submit the data to the backend...
299
278
 
300
279
 
301
- hooks.onSubmit(action.type, _submissionData, function (response) {
280
+ hooks.onSubmit(action.type, submissionData, function (response) {
302
281
  // The backend response may well contain data we need so apply it...
303
282
  // ... but this needs to happen in a useEffect, not right away.
304
- var sData = _objectSpread(_objectSpread({}, _submissionData), response);
283
+ var sData = _objectSpread(_objectSpread({}, submissionData), response);
305
284
 
306
285
  setSubmitted({
307
286
  data: sData
@@ -364,14 +343,14 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
364
343
 
365
344
  if (action.type === _models.PageAction.TYPES.SAVE_AND_CONTINUE && hub === _models.HubFormats.TASK) {
366
345
  if (_helpers.default.canCYASubmit(currentTask.fullPages, validate.pages)) {
367
- var _submissionData2 = _utils.default.Format.form({
346
+ var _submissionData = _utils.default.Format.form({
368
347
  pages: pages,
369
348
  components: components
370
349
  }, _objectSpread({}, data), _models.EventTypes.SUBMIT);
371
350
 
372
- _submissionData2.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData2, currentTask, true);
373
- setData(_submissionData2);
374
- hooks.onSubmit(action.type, _submissionData2, function () {
351
+ _submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData, currentTask, true);
352
+ setData(_submissionData);
353
+ hooks.onSubmit(action.type, _submissionData, function () {
375
354
  return onPageChange(_models.FormPages.HUB);
376
355
  }, function (errors) {
377
356
  return _handlers.default.submissionError(errors, addErrors);
@@ -381,14 +360,14 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
381
360
 
382
361
  if (action.type === _models.PageAction.TYPES.SAVE_AND_RETURN) {
383
362
  if (_helpers.default.canCYASubmit(currentTask.fullPages, validate.pages)) {
384
- var _submissionData3 = _utils.default.Format.form({
363
+ var _submissionData2 = _utils.default.Format.form({
385
364
  pages: pages,
386
365
  components: components
387
366
  }, _objectSpread({}, data), _models.EventTypes.SUBMIT);
388
367
 
389
- _submissionData3.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData3, currentTask);
390
- setData(_submissionData3);
391
- hooks.onSubmit(action.type, _submissionData3, function () {
368
+ _submissionData2.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData2, currentTask);
369
+ setData(_submissionData2);
370
+ hooks.onSubmit(action.type, _submissionData2, function () {
392
371
  if (type === _models.FormTypes.TASK) {
393
372
  onPageChange(undefined);
394
373
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "3.2.2",
3
+ "version": "3.2.3",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",