From d59fd638bd6cb10bf59c74badb052388f92f7b6e Mon Sep 17 00:00:00 2001 From: Michael Clement Date: Thu, 9 May 2024 08:56:03 -0500 Subject: [PATCH] adjusted keynames and added some logging (#29646) --- .../ivc-champva/10-7959f-1/config/form.js | 37 +++++++++++++++++-- .../10-7959f-1/config/prefillTransformer.js | 2 +- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/applications/ivc-champva/10-7959f-1/config/form.js b/src/applications/ivc-champva/10-7959f-1/config/form.js index 328835a17339..aec1b5d7a5fd 100644 --- a/src/applications/ivc-champva/10-7959f-1/config/form.js +++ b/src/applications/ivc-champva/10-7959f-1/config/form.js @@ -20,6 +20,10 @@ import { // checkboxGroupSchema, } from 'platform/forms-system/src/js/web-component-patterns'; +import { + getNextPagePath, + checkValidPagePath, +} from '@department-of-veterans-affairs/platform-forms-system/routing'; import transformForSubmit from './submitTransformer'; import manifest from '../manifest.json'; import prefillTransformer from './prefillTransformer'; @@ -49,6 +53,31 @@ const formConfig = { customText: { appType: 'form', }, + // This is here temporarily to allow us to log SIP/Prefill data on staging + onFormLoaded: props => { + // TODO: Remove all this when we've verified we're getting the right data. + const { formData, returnUrl } = props; + // Check valid return URL; copied from RoutedSavableApp + const isValidReturnUrl = checkValidPagePath( + props.routes[props.routes.length - 1].pageList, + formData, + returnUrl, + ); + if (isValidReturnUrl) { + props.router.push(returnUrl); + } else { + const nextPagePath = getNextPagePath( + props.routes[props.routes.length - 1].pageList, + formData, + '/introduction', + ); + props.router.push(nextPagePath); + } + // Show whatever formData we have at this time, which should include data + // produced by the prefill transformer + // eslint-disable-next-line no-console + console.log('Form loaded - data: ', formData); + }, preSubmitInfo: { statementOfTruth: { body: @@ -94,11 +123,11 @@ const formConfig = { messageAriaDescribedby: 'We use this information to verify other details.', veteranFullName: veteranFullNameUI, - veteranDateOfBirth: dateOfBirthUI(), + veteranDateOfBirth: dateOfBirthUI({ required: true }), }, schema: { type: 'object', - required: ['fullName', 'veteranDOB'], + required: ['veteranFullName', 'veteranDateOfBirth'], properties: { titleSchema, veteranFullName: fullNameSchema, @@ -125,7 +154,7 @@ const formConfig = { }, schema: { type: 'object', - required: ['ssn'], + required: ['veteranSocialSecurityNumber'], properties: { titleSchema, veteranSocialSecurityNumber: ssnOrVaFileNumberSchema, @@ -159,7 +188,7 @@ const formConfig = { }, schema: { type: 'object', - required: ['mailingAddress'], + required: ['veteranAddress'], properties: { titleSchema, veteranAddress: addressSchema({ diff --git a/src/applications/ivc-champva/10-7959f-1/config/prefillTransformer.js b/src/applications/ivc-champva/10-7959f-1/config/prefillTransformer.js index 586e3f22b485..162fe9e80ca9 100644 --- a/src/applications/ivc-champva/10-7959f-1/config/prefillTransformer.js +++ b/src/applications/ivc-champva/10-7959f-1/config/prefillTransformer.js @@ -1,4 +1,4 @@ -const prefillTransformer = (pages, metadata, formData) => { +const prefillTransformer = (pages, formData, metadata) => { return { pages, formData: {