diff --git a/src/applications/pensions/config/chapters/01-applicant-information/applicantInformation.js b/src/applications/pensions/config/chapters/01-applicant-information/applicantInformation.js
index 5adf52854a21..d837cf610ba5 100644
--- a/src/applications/pensions/config/chapters/01-applicant-information/applicantInformation.js
+++ b/src/applications/pensions/config/chapters/01-applicant-information/applicantInformation.js
@@ -1,5 +1,4 @@
import moment from 'moment';
-
import {
dateOfBirthUI,
dateOfBirthSchema,
@@ -44,8 +43,8 @@ export function setDefaultIsOver65(oldData, newData, currentDate) {
/** @type {PageSchema} */
export default {
- path: 'applicant/information',
title: 'Applicant information',
+ path: 'applicant/information',
updateFormData: setDefaultIsOver65,
uiSchema: {
'ui:description': applicantDescription,
diff --git a/src/applications/pensions/config/chapters/02-military-history/generalHistory.js b/src/applications/pensions/config/chapters/02-military-history/generalHistory.js
index 2bfc5a55eeda..082bbbec2f34 100644
--- a/src/applications/pensions/config/chapters/02-military-history/generalHistory.js
+++ b/src/applications/pensions/config/chapters/02-military-history/generalHistory.js
@@ -6,8 +6,8 @@ import {
/** @type {PageSchema} */
export default {
- path: 'military/general',
title: 'General history',
+ path: 'military/general',
uiSchema: {
...titleUI('Other service names'),
serveUnderOtherNames: yesNoUI({
diff --git a/src/applications/pensions/config/chapters/02-military-history/pow.js b/src/applications/pensions/config/chapters/02-military-history/pow.js
index 2aa4051a803f..3aaaf15d4f15 100644
--- a/src/applications/pensions/config/chapters/02-military-history/pow.js
+++ b/src/applications/pensions/config/chapters/02-military-history/pow.js
@@ -8,8 +8,8 @@ import {
/** @type {PageSchema} */
export default {
- path: 'military/pow',
title: 'POW status',
+ path: 'military/pow',
uiSchema: {
...titleUI('Prisoner of war status'),
powStatus: yesNoUI({
diff --git a/src/applications/pensions/config/chapters/02-military-history/previousNames.js b/src/applications/pensions/config/chapters/02-military-history/previousNames.js
index b278ad4dfe4c..8f33576f9d63 100644
--- a/src/applications/pensions/config/chapters/02-military-history/previousNames.js
+++ b/src/applications/pensions/config/chapters/02-military-history/previousNames.js
@@ -21,8 +21,8 @@ PreviousNameView.propTypes = {
/** @type {PageSchema} */
export default {
- path: 'military/general/add',
title: 'Previous names',
+ path: 'military/general/add',
depends: doesHavePreviousNames,
uiSchema: {
...titleUI('Add other service names'),
diff --git a/src/applications/pensions/config/chapters/02-military-history/servicePeriod.js b/src/applications/pensions/config/chapters/02-military-history/servicePeriod.js
index d91b46a1fb95..650bdeda7844 100644
--- a/src/applications/pensions/config/chapters/02-military-history/servicePeriod.js
+++ b/src/applications/pensions/config/chapters/02-military-history/servicePeriod.js
@@ -1,7 +1,5 @@
import fullSchemaPensions from 'vets-json-schema/dist/21P-527EZ-schema.json';
-
import { createSelector } from 'reselect';
-
import { isFullDate } from 'platform/forms/validations';
import {
currentOrPastDateRangeUI,
@@ -13,19 +11,18 @@ import {
titleUI,
} from 'platform/forms-system/src/js/web-component-patterns';
import { VaTextInputField } from 'platform/forms-system/src/js/web-component-fields';
-
-const { placeOfSeparation } = fullSchemaPensions.properties;
-
import { serviceBranchLabels } from '../../../labels';
import { WartimeWarningAlert } from '../../../components/FormAlerts';
import { servedDuringWartime } from '../../../helpers';
import { validateServiceBirthDates } from '../../../validation';
import ServicePeriodReview from '../../../components/ServicePeriodReview';
+const { placeOfSeparation } = fullSchemaPensions.properties;
+
/** @type {PageSchema} */
export default {
- path: 'military/history',
title: 'Service period',
+ path: 'military/history',
CustomPageReview: ServicePeriodReview,
uiSchema: {
...titleUI('Service period'),
diff --git a/src/applications/pensions/config/chapters/03-health-and-employment-information/currentEmploymentHistory.js b/src/applications/pensions/config/chapters/03-health-and-employment-information/currentEmploymentHistory.js
index 02e13ee03b6a..5d3b47c13c85 100644
--- a/src/applications/pensions/config/chapters/03-health-and-employment-information/currentEmploymentHistory.js
+++ b/src/applications/pensions/config/chapters/03-health-and-employment-information/currentEmploymentHistory.js
@@ -1,5 +1,4 @@
-import generateEmployersSchemas from './employmentHistory';
-import { isEmployedUnder65 } from './helpers';
+import { generateEmployersSchemas, isEmployedUnder65 } from './helpers';
export default {
title: 'Current employment',
diff --git a/src/applications/pensions/config/chapters/03-health-and-employment-information/employmentHistory.js b/src/applications/pensions/config/chapters/03-health-and-employment-information/employmentHistory.js
deleted file mode 100644
index 64e5b2e03783..000000000000
--- a/src/applications/pensions/config/chapters/03-health-and-employment-information/employmentHistory.js
+++ /dev/null
@@ -1,159 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-
-import { VaTextInputField } from 'platform/forms-system/src/js/web-component-fields';
-import {
- currentOrPastDateUI,
- currentOrPastDateSchema,
- numberUI,
- numberSchema,
- titleUI,
-} from 'platform/forms-system/src/js/web-component-patterns';
-import ListItemView from '../../../components/ListItemView';
-
-import {
- getJobTitleOrType,
- updateMultiresponseUiOptions,
-} from '../../../helpers';
-
-export const EmployerView = ({ formData }) => (
-
-);
-
-EmployerView.propTypes = {
- formData: PropTypes.shape({
- jobTitle: PropTypes.string,
- }),
-};
-
-const generateEmployersUISchema = ({
- employersKey,
- employersTitle,
- employerMessage,
- jobTypeFieldLabel,
- jobHoursWeekFieldLabel,
- jobTitleFieldLabel,
- employersReviewTitle,
- showJobDateField,
- showJobTitleField,
-}) => ({
- ...titleUI(employersTitle),
- [employersKey]: {
- 'ui:title': employerMessage,
- 'ui:options': {
- itemName: 'Job',
- itemAriaLabel: data => getJobTitleOrType(data.jobTitle),
- viewField: EmployerView,
- reviewTitle: employersReviewTitle,
- keepInPageOnReview: true,
- customTitle: ' ',
- confirmRemove: true,
- useDlWrap: true,
- useVaCards: true,
- updateSchema: updateMultiresponseUiOptions,
- },
- items: {
- ...(showJobDateField && {
- jobDate: currentOrPastDateUI('When did you last work?'),
- }),
- jobType: {
- 'ui:title': jobTypeFieldLabel,
- 'ui:webComponentField': VaTextInputField,
- },
- jobHoursWeek: numberUI({
- title: jobHoursWeekFieldLabel,
- width: 'sm',
- min: 1,
- max: 168,
- }),
- ...(showJobTitleField && {
- jobTitle: {
- 'ui:title': jobTitleFieldLabel,
- 'ui:webComponentField': VaTextInputField,
- },
- }),
- },
- },
-});
-
-const generateEmployersSchema = ({
- employersKey,
- maxEmployersAmount,
- showJobTitleField,
- showJobDateField,
-}) => ({
- type: 'object',
- properties: {
- [employersKey]: {
- type: 'array',
- minItems: 1,
- maxItems: maxEmployersAmount,
- items: {
- type: 'object',
- required: showJobTitleField
- ? ['jobType', 'jobHoursWeek', 'jobTitle']
- : ['jobType', 'jobHoursWeek'],
- properties: {
- ...(showJobDateField && { jobDate: currentOrPastDateSchema }),
- jobType: {
- type: 'string',
- },
- jobHoursWeek: numberSchema,
- ...(showJobTitleField && {
- jobTitle: {
- type: 'string',
- },
- }),
- },
- },
- },
- },
-});
-
-/**
- * Function to generate UI Schema and Schema for employment history
- * @param {string} employersKey - Key for employers in the schema
- * @param {string} employersTitle - Title for the employers in UI
- * @param {string} employerMessage - Message for individual employers in UI
- * @param {string} jobTypeFieldLabel - Label for the job type field in UI
- * @param {string} jobHoursWeekFieldLabel - Label for the job hours per week field in UI
- * @param {string} jobTitleFieldLabel - Label for the job title field in UI
- * @param {string} employersReviewTitle - Review title for employers
- * @param {number} maxEmployersAmount - Optional maximum number of employers
- * @param {boolean} showJobDateField - Optional job date field in UI
- * @returns {Object} - Object containing uiSchema and schema
- */
-const generateEmployersSchemas = ({
- employersKey = 'employers',
- employersTitle = 'Default Employers Title',
- employerMessage = 'Default Message',
- jobTypeFieldLabel = 'Default Field Label',
- jobHoursWeekFieldLabel = 'Default Field Label',
- jobTitleFieldLabel = 'Default Field Label',
- employersReviewTitle = 'Default Review Title',
- maxEmployersAmount = 2,
- showJobDateField = false,
- showJobTitleField = false,
-}) => {
- return {
- uiSchema: generateEmployersUISchema({
- employersKey,
- employersTitle,
- employerMessage,
- jobTypeFieldLabel,
- jobHoursWeekFieldLabel,
- jobTitleFieldLabel,
- employersReviewTitle,
- showJobDateField,
- showJobTitleField,
- }),
- schema: generateEmployersSchema({
- employersKey,
- maxEmployersAmount,
- showJobTitleField,
- showJobDateField,
- }),
- };
-};
-
-export default generateEmployersSchemas;
diff --git a/src/applications/pensions/config/chapters/03-health-and-employment-information/federalMedicalCenters.js b/src/applications/pensions/config/chapters/03-health-and-employment-information/federalMedicalCenters.js
index ae09586d0d3d..2ca93f33f247 100644
--- a/src/applications/pensions/config/chapters/03-health-and-employment-information/federalMedicalCenters.js
+++ b/src/applications/pensions/config/chapters/03-health-and-employment-information/federalMedicalCenters.js
@@ -1,5 +1,7 @@
-import generateMedicalCentersSchemas from './medicalCenters';
-import { hasFederalTreatmentHistory } from './helpers';
+import {
+ generateMedicalCentersSchemas,
+ hasFederalTreatmentHistory,
+} from './helpers';
export default {
title: 'Federal medical facilities',
diff --git a/src/applications/pensions/config/chapters/03-health-and-employment-information/helpers.js b/src/applications/pensions/config/chapters/03-health-and-employment-information/helpers.js
index 417e5117b391..c4bea25d37fa 100644
--- a/src/applications/pensions/config/chapters/03-health-and-employment-information/helpers.js
+++ b/src/applications/pensions/config/chapters/03-health-and-employment-information/helpers.js
@@ -1,11 +1,28 @@
import moment from 'moment/moment';
+import React from 'react';
+import PropTypes from 'prop-types';
+import { VaTextInputField } from 'platform/forms-system/src/js/web-component-fields';
+import {
+ currentOrPastDateUI,
+ currentOrPastDateSchema,
+ numberUI,
+ numberSchema,
+ titleUI,
+} from 'platform/forms-system/src/js/web-component-patterns';
+import ListItemView from '../../../components/ListItemView';
+import {
+ getJobTitleOrType,
+ updateMultiresponseUiOptions,
+} from '../../../helpers';
export function hasFederalTreatmentHistory(formData) {
return formData.federalTreatmentHistory === true;
}
+
export function hasNoSocialSecurityDisability(formData) {
return formData.socialSecurityDisability === false;
}
+
export function hasVaTreatmentHistory(formData) {
return formData.vaTreatmentHistory === true;
}
@@ -35,3 +52,215 @@ export function isUnemployedUnder65(formData) {
export function medicaidDoesNotCoverNursingHome(formData) {
return formData.nursingHome === true && formData.medicaidCoverage === false;
}
+
+const MedicalCenterView = ({ formData }) => (
+
+);
+
+MedicalCenterView.propTypes = {
+ formData: PropTypes.shape({
+ medicalCenter: PropTypes.string,
+ }),
+};
+
+/**
+ * Function to generate UI Schema and Schema for medical centers
+ * @param {string} medicalCentersKey - Key for medical centers in the schema
+ * @param {string} medicalCentersTitle - Title for the medical centers in UI
+ * @param {string} medicalCenterMessage - Message for individual medical centers in UI
+ * @param {string} medicalCenterFieldLabel - Label for the medical center field in UI
+ * @param {string} medicalCentersReviewTitle - Review title for medical centers
+ * @returns {Object} - Object containing uiSchema and schema
+ */
+export const generateMedicalCentersSchemas = (
+ medicalCentersKey = 'medicalCenters',
+ medicalCentersTitle = 'Default Medical Centers Title',
+ medicalCenterMessage = 'Default Message',
+ medicalCenterFieldLabel = 'Default Field Label',
+ medicalCentersReviewTitle = 'Default Review Title',
+) => {
+ return {
+ uiSchema: {
+ ...titleUI(medicalCentersTitle),
+ [medicalCentersKey]: {
+ 'ui:title': medicalCenterMessage,
+ 'ui:options': {
+ itemName: 'Medical center',
+ itemAriaLabel: data => data.medicalCenter,
+ viewField: MedicalCenterView,
+ reviewTitle: medicalCentersReviewTitle,
+ keepInPageOnReview: true,
+ customTitle: ' ',
+ confirmRemove: true,
+ useDlWrap: true,
+ useVaCards: true,
+ updateSchema: updateMultiresponseUiOptions,
+ },
+ items: {
+ medicalCenter: {
+ 'ui:title': medicalCenterFieldLabel,
+ 'ui:webComponentField': VaTextInputField,
+ },
+ },
+ },
+ },
+ schema: {
+ type: 'object',
+ properties: {
+ [medicalCentersKey]: {
+ type: 'array',
+ minItems: 1,
+ items: {
+ type: 'object',
+ required: ['medicalCenter'],
+ properties: {
+ medicalCenter: {
+ type: 'string',
+ },
+ },
+ },
+ },
+ },
+ },
+ };
+};
+
+export const EmployerView = ({ formData }) => (
+
+);
+
+EmployerView.propTypes = {
+ formData: PropTypes.shape({
+ jobTitle: PropTypes.string,
+ }),
+};
+
+const generateEmployersUISchema = ({
+ employersKey,
+ employersTitle,
+ employerMessage,
+ jobTypeFieldLabel,
+ jobHoursWeekFieldLabel,
+ jobTitleFieldLabel,
+ employersReviewTitle,
+ showJobDateField,
+ showJobTitleField,
+}) => ({
+ ...titleUI(employersTitle),
+ [employersKey]: {
+ 'ui:title': employerMessage,
+ 'ui:options': {
+ itemName: 'Job',
+ itemAriaLabel: data => getJobTitleOrType(data.jobTitle),
+ viewField: EmployerView,
+ reviewTitle: employersReviewTitle,
+ keepInPageOnReview: true,
+ customTitle: ' ',
+ confirmRemove: true,
+ useDlWrap: true,
+ useVaCards: true,
+ updateSchema: updateMultiresponseUiOptions,
+ },
+ items: {
+ ...(showJobDateField && {
+ jobDate: currentOrPastDateUI('When did you last work?'),
+ }),
+ jobType: {
+ 'ui:title': jobTypeFieldLabel,
+ 'ui:webComponentField': VaTextInputField,
+ },
+ jobHoursWeek: numberUI({
+ title: jobHoursWeekFieldLabel,
+ width: 'sm',
+ min: 1,
+ max: 168,
+ }),
+ ...(showJobTitleField && {
+ jobTitle: {
+ 'ui:title': jobTitleFieldLabel,
+ 'ui:webComponentField': VaTextInputField,
+ },
+ }),
+ },
+ },
+});
+
+const generateEmployersSchema = ({
+ employersKey,
+ maxEmployersAmount,
+ showJobTitleField,
+ showJobDateField,
+}) => ({
+ type: 'object',
+ properties: {
+ [employersKey]: {
+ type: 'array',
+ minItems: 1,
+ maxItems: maxEmployersAmount,
+ items: {
+ type: 'object',
+ required: showJobTitleField
+ ? ['jobType', 'jobHoursWeek', 'jobTitle']
+ : ['jobType', 'jobHoursWeek'],
+ properties: {
+ ...(showJobDateField && { jobDate: currentOrPastDateSchema }),
+ jobType: {
+ type: 'string',
+ },
+ jobHoursWeek: numberSchema,
+ ...(showJobTitleField && {
+ jobTitle: {
+ type: 'string',
+ },
+ }),
+ },
+ },
+ },
+ },
+});
+
+/**
+ * Function to generate UI Schema and Schema for employment history
+ * @param {string} employersKey - Key for employers in the schema
+ * @param {string} employersTitle - Title for the employers in UI
+ * @param {string} employerMessage - Message for individual employers in UI
+ * @param {string} jobTypeFieldLabel - Label for the job type field in UI
+ * @param {string} jobHoursWeekFieldLabel - Label for the job hours per week field in UI
+ * @param {string} jobTitleFieldLabel - Label for the job title field in UI
+ * @param {string} employersReviewTitle - Review title for employers
+ * @param {number} maxEmployersAmount - Optional maximum number of employers
+ * @param {boolean} showJobDateField - Optional job date field in UI
+ * @returns {Object} - Object containing uiSchema and schema
+ */
+export const generateEmployersSchemas = ({
+ employersKey = 'employers',
+ employersTitle = 'Default Employers Title',
+ employerMessage = 'Default Message',
+ jobTypeFieldLabel = 'Default Field Label',
+ jobHoursWeekFieldLabel = 'Default Field Label',
+ jobTitleFieldLabel = 'Default Field Label',
+ employersReviewTitle = 'Default Review Title',
+ maxEmployersAmount = 2,
+ showJobDateField = false,
+ showJobTitleField = false,
+}) => {
+ return {
+ uiSchema: generateEmployersUISchema({
+ employersKey,
+ employersTitle,
+ employerMessage,
+ jobTypeFieldLabel,
+ jobHoursWeekFieldLabel,
+ jobTitleFieldLabel,
+ employersReviewTitle,
+ showJobDateField,
+ showJobTitleField,
+ }),
+ schema: generateEmployersSchema({
+ employersKey,
+ maxEmployersAmount,
+ showJobTitleField,
+ showJobDateField,
+ }),
+ };
+};
diff --git a/src/applications/pensions/config/chapters/03-health-and-employment-information/medicalCenters.js b/src/applications/pensions/config/chapters/03-health-and-employment-information/medicalCenters.js
deleted file mode 100644
index 1e805337cf6f..000000000000
--- a/src/applications/pensions/config/chapters/03-health-and-employment-information/medicalCenters.js
+++ /dev/null
@@ -1,81 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-
-import { titleUI } from 'platform/forms-system/src/js/web-component-patterns';
-import { VaTextInputField } from 'platform/forms-system/src/js/web-component-fields';
-import ListItemView from '../../../components/ListItemView';
-import { updateMultiresponseUiOptions } from '../../../helpers';
-
-const MedicalCenterView = ({ formData }) => (
-
-);
-
-MedicalCenterView.propTypes = {
- formData: PropTypes.shape({
- medicalCenter: PropTypes.string,
- }),
-};
-
-/**
- * Function to generate UI Schema and Schema for medical centers
- * @param {string} medicalCentersKey - Key for medical centers in the schema
- * @param {string} medicalCentersTitle - Title for the medical centers in UI
- * @param {string} medicalCenterMessage - Message for individual medical centers in UI
- * @param {string} medicalCenterFieldLabel - Label for the medical center field in UI
- * @param {string} medicalCentersReviewTitle - Review title for medical centers
- * @returns {Object} - Object containing uiSchema and schema
- */
-const generateMedicalCentersSchemas = (
- medicalCentersKey = 'medicalCenters',
- medicalCentersTitle = 'Default Medical Centers Title',
- medicalCenterMessage = 'Default Message',
- medicalCenterFieldLabel = 'Default Field Label',
- medicalCentersReviewTitle = 'Default Review Title',
-) => {
- return {
- uiSchema: {
- ...titleUI(medicalCentersTitle),
- [medicalCentersKey]: {
- 'ui:title': medicalCenterMessage,
- 'ui:options': {
- itemName: 'Medical center',
- itemAriaLabel: data => data.medicalCenter,
- viewField: MedicalCenterView,
- reviewTitle: medicalCentersReviewTitle,
- keepInPageOnReview: true,
- customTitle: ' ',
- confirmRemove: true,
- useDlWrap: true,
- useVaCards: true,
- updateSchema: updateMultiresponseUiOptions,
- },
- items: {
- medicalCenter: {
- 'ui:title': medicalCenterFieldLabel,
- 'ui:webComponentField': VaTextInputField,
- },
- },
- },
- },
- schema: {
- type: 'object',
- properties: {
- [medicalCentersKey]: {
- type: 'array',
- minItems: 1,
- items: {
- type: 'object',
- required: ['medicalCenter'],
- properties: {
- medicalCenter: {
- type: 'string',
- },
- },
- },
- },
- },
- },
- };
-};
-
-export default generateMedicalCentersSchemas;
diff --git a/src/applications/pensions/config/chapters/03-health-and-employment-information/previousEmploymentHistory.js b/src/applications/pensions/config/chapters/03-health-and-employment-information/previousEmploymentHistory.js
index 58e3f01182b7..da1739668a23 100644
--- a/src/applications/pensions/config/chapters/03-health-and-employment-information/previousEmploymentHistory.js
+++ b/src/applications/pensions/config/chapters/03-health-and-employment-information/previousEmploymentHistory.js
@@ -1,5 +1,4 @@
-import generateEmployersSchemas from './employmentHistory';
-import { isUnemployedUnder65 } from './helpers';
+import { generateEmployersSchemas, isUnemployedUnder65 } from './helpers';
export default {
title: 'Previous employment',
diff --git a/src/applications/pensions/config/chapters/03-health-and-employment-information/specialMonthlyPension.js b/src/applications/pensions/config/chapters/03-health-and-employment-information/specialMonthlyPension.js
index d1ddb84fd220..b022f5acbd4b 100644
--- a/src/applications/pensions/config/chapters/03-health-and-employment-information/specialMonthlyPension.js
+++ b/src/applications/pensions/config/chapters/03-health-and-employment-information/specialMonthlyPension.js
@@ -4,7 +4,6 @@ import {
yesNoSchema,
yesNoUI,
} from 'platform/forms-system/src/js/web-component-patterns';
-
import { SpecialMonthlyPensionEvidenceAlert } from '../../../components/FormAlerts';
const Description = (
diff --git a/src/applications/pensions/config/chapters/03-health-and-employment-information/vaMedicalCenters.js b/src/applications/pensions/config/chapters/03-health-and-employment-information/vaMedicalCenters.js
index 90e710667e08..10128a2f363a 100644
--- a/src/applications/pensions/config/chapters/03-health-and-employment-information/vaMedicalCenters.js
+++ b/src/applications/pensions/config/chapters/03-health-and-employment-information/vaMedicalCenters.js
@@ -1,5 +1,7 @@
-import generateMedicalCentersSchemas from './medicalCenters';
-import { hasVaTreatmentHistory } from './helpers';
+import {
+ generateMedicalCentersSchemas,
+ hasVaTreatmentHistory,
+} from './helpers';
export default {
title: 'VA medical centers',
diff --git a/src/applications/pensions/config/chapters/04-household-information/currentSpouseFormerMarriages.jsx b/src/applications/pensions/config/chapters/04-household-information/currentSpouseFormerMarriages.jsx
index 457863b7df91..81f32fcf647f 100644
--- a/src/applications/pensions/config/chapters/04-household-information/currentSpouseFormerMarriages.jsx
+++ b/src/applications/pensions/config/chapters/04-household-information/currentSpouseFormerMarriages.jsx
@@ -1,9 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import get from 'platform/utilities/data/get';
-
import fullSchemaPensions from 'vets-json-schema/dist/21P-527EZ-schema.json';
-
import {
currentOrPastDateUI,
fullNameUI,
@@ -13,7 +11,6 @@ import {
titleUI,
} from 'platform/forms-system/src/js/web-component-patterns';
import { VaTextInputField } from 'platform/forms-system/src/js/web-component-fields';
-
import {
ContactWarningAlert,
ContactWarningMultiAlert,
@@ -22,7 +19,6 @@ import { formatFullName } from '../../../helpers';
import ListItemView from '../../../components/ListItemView';
import SpouseMarriageTitle from '../../../components/SpouseMarriageTitle';
import { separationTypeLabels } from '../../../labels';
-
import {
validateAfterMarriageDates,
validateUniqueMarriageDates,
diff --git a/src/applications/pensions/config/chapters/04-household-information/dependentChildAddress.js b/src/applications/pensions/config/chapters/04-household-information/dependentChildAddress.js
index 0c9cbbdad7df..f43d1f7251e7 100644
--- a/src/applications/pensions/config/chapters/04-household-information/dependentChildAddress.js
+++ b/src/applications/pensions/config/chapters/04-household-information/dependentChildAddress.js
@@ -12,8 +12,8 @@ import createHouseholdMemberTitle from '../../../components/DisclosureTitle';
/** @type {PageSchema} */
export default {
- path: 'household/dependents/children/address/:index',
title: item => getDependentChildTitle(item, 'address'),
+ path: 'household/dependents/children/address/:index',
depends: dependentIsOutsideHousehold,
showPagePerItem: true,
arrayPath: 'dependents',
diff --git a/src/applications/pensions/config/chapters/04-household-information/dependentChildInHousehold.js b/src/applications/pensions/config/chapters/04-household-information/dependentChildInHousehold.js
index 584bf9d7807d..ebab8bfc67d7 100644
--- a/src/applications/pensions/config/chapters/04-household-information/dependentChildInHousehold.js
+++ b/src/applications/pensions/config/chapters/04-household-information/dependentChildInHousehold.js
@@ -3,17 +3,25 @@ import {
yesNoSchema,
yesNoUI,
} from 'platform/forms-system/src/js/web-component-patterns';
-
import createHouseholdMemberTitle from '../../../components/DisclosureTitle';
-
import { doesHaveDependents, getDependentChildTitle } from './helpers';
export default {
- path: 'household/dependents/children/inhousehold/:index',
title: item => getDependentChildTitle(item, 'household'),
+ path: 'household/dependents/children/inhousehold/:index',
depends: doesHaveDependents,
showPagePerItem: true,
arrayPath: 'dependents',
+ uiSchema: {
+ dependents: {
+ items: {
+ ...titleUI(createHouseholdMemberTitle('fullName', 'household')),
+ childInHousehold: yesNoUI({
+ title: 'Does your child live with you?',
+ }),
+ },
+ },
+ },
schema: {
type: 'object',
properties: {
@@ -29,14 +37,4 @@ export default {
},
},
},
- uiSchema: {
- dependents: {
- items: {
- ...titleUI(createHouseholdMemberTitle('fullName', 'household')),
- childInHousehold: yesNoUI({
- title: 'Does your child live with you?',
- }),
- },
- },
- },
};
diff --git a/src/applications/pensions/config/chapters/04-household-information/dependentChildInformation.js b/src/applications/pensions/config/chapters/04-household-information/dependentChildInformation.js
index 194e239c9d3f..e1d7c4a8081b 100644
--- a/src/applications/pensions/config/chapters/04-household-information/dependentChildInformation.js
+++ b/src/applications/pensions/config/chapters/04-household-information/dependentChildInformation.js
@@ -1,6 +1,5 @@
import merge from 'lodash/merge';
import moment from 'moment';
-
import {
radioSchema,
radioUI,
@@ -10,23 +9,18 @@ import {
yesNoSchema,
yesNoUI,
} from 'platform/forms-system/src/js/web-component-patterns';
-
import {
VaCheckboxField,
VaTextInputField,
} from 'platform/forms-system/src/js/web-component-fields';
-
import get from 'platform/utilities/data/get';
-
import createHouseholdMemberTitle from '../../../components/DisclosureTitle';
-
import { DependentSeriouslyDisabledDescription } from '../../../helpers';
import {
DisabilityDocsAlert,
SchoolAttendanceAlert,
AdoptionEvidenceAlert,
} from '../../../components/FormAlerts';
-
import { doesHaveDependents, getDependentChildTitle } from './helpers';
const childRelationshipOptions = {
@@ -48,8 +42,8 @@ function isBetween18And23(childDOB) {
/** @type {PageSchema} */
export default {
- path: 'household/dependents/children/information/:index',
title: item => getDependentChildTitle(item, 'information'),
+ path: 'household/dependents/children/information/:index',
depends: doesHaveDependents,
showPagePerItem: true,
arrayPath: 'dependents',
diff --git a/src/applications/pensions/config/chapters/04-household-information/dependentChildren.js b/src/applications/pensions/config/chapters/04-household-information/dependentChildren.js
index e2149483bebe..f4c29df49473 100644
--- a/src/applications/pensions/config/chapters/04-household-information/dependentChildren.js
+++ b/src/applications/pensions/config/chapters/04-household-information/dependentChildren.js
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
-
import {
dateOfBirthUI,
dateOfBirthSchema,
diff --git a/src/applications/pensions/config/chapters/04-household-information/helpers.jsx b/src/applications/pensions/config/chapters/04-household-information/helpers.jsx
index 5024cb492a42..1ec25185fa83 100644
--- a/src/applications/pensions/config/chapters/04-household-information/helpers.jsx
+++ b/src/applications/pensions/config/chapters/04-household-information/helpers.jsx
@@ -8,9 +8,11 @@ import React from 'react';
export function isSeparated(formData) {
return formData.maritalStatus === 'SEPARATED';
}
+
export function isMarried(form = {}) {
return ['MARRIED', 'SEPARATED'].includes(form.maritalStatus);
}
+
export function doesHaveDependents(formData) {
return get(['view:hasDependents'], formData) === true;
}
@@ -60,7 +62,7 @@ export function getDependentChildTitle(item, description) {
return `${item.fullName.first || ''} ${item.fullName.last ||
''} ${description}`;
}
- return 'description';
+ return description;
}
export function createSpouseLabelSelector(nameTemplate) {
diff --git a/src/applications/pensions/config/chapters/04-household-information/marriageHistory.js b/src/applications/pensions/config/chapters/04-household-information/marriageHistory.js
index fc886d717867..acfe779c140c 100644
--- a/src/applications/pensions/config/chapters/04-household-information/marriageHistory.js
+++ b/src/applications/pensions/config/chapters/04-household-information/marriageHistory.js
@@ -1,10 +1,8 @@
import get from 'platform/utilities/data/get';
import merge from 'lodash/merge';
-
// Use date widget because currentOrPastDate web component does not work with array
// list loop data as a show per page item
import currentOrPastDateUI from 'platform/forms-system/src/js/definitions/currentOrPastDate';
-
import { VaTextInputField } from 'platform/forms-system/src/js/web-component-fields';
import {
fullNameNoSuffixUI,
diff --git a/src/applications/pensions/config/chapters/04-household-information/spouseInfo.js b/src/applications/pensions/config/chapters/04-household-information/spouseInfo.js
index 01f9807e4255..dce91d4597fd 100644
--- a/src/applications/pensions/config/chapters/04-household-information/spouseInfo.js
+++ b/src/applications/pensions/config/chapters/04-household-information/spouseInfo.js
@@ -1,5 +1,4 @@
import merge from 'lodash/merge';
-
import {
dateOfBirthSchema,
dateOfBirthUI,
@@ -11,7 +10,6 @@ import {
yesNoSchema,
yesNoUI,
} from 'platform/forms-system/src/js/web-component-patterns';
-
import { createSpouseLabelSelector, isMarried } from './helpers';
import createHouseholdMemberTitle from '../../../components/DisclosureTitle';
diff --git a/src/applications/pensions/config/chapters/05-financial-information/careExpenses.js b/src/applications/pensions/config/chapters/05-financial-information/careExpenses.js
index f4583e3c98c4..4f8a4ed55b09 100644
--- a/src/applications/pensions/config/chapters/05-financial-information/careExpenses.js
+++ b/src/applications/pensions/config/chapters/05-financial-information/careExpenses.js
@@ -43,8 +43,8 @@ CareExpenseView.propTypes = {
/** @type {PageSchema} */
export default {
- path: 'financial/care-expenses/add',
title: 'Unreimbursed care expenses',
+ path: 'financial/care-expenses/add',
depends: doesHaveCareExpenses,
uiSchema: {
...titleUI('Add an unreimbursed care expense'),
diff --git a/src/applications/pensions/config/chapters/05-financial-information/hasCareExpenses.js b/src/applications/pensions/config/chapters/05-financial-information/hasCareExpenses.js
index 835dd9496be4..a613f0b5a81a 100644
--- a/src/applications/pensions/config/chapters/05-financial-information/hasCareExpenses.js
+++ b/src/applications/pensions/config/chapters/05-financial-information/hasCareExpenses.js
@@ -18,8 +18,8 @@ export const description = (
/** @type {PageSchema} */
export default {
- path: 'financial/care-expenses',
title: 'Care expenses',
+ path: 'financial/care-expenses',
uiSchema: {
...titleUI('Care expenses', description),
hasCareExpenses: yesNoUI({
diff --git a/src/applications/pensions/config/chapters/05-financial-information/hasMedicalExpenses.js b/src/applications/pensions/config/chapters/05-financial-information/hasMedicalExpenses.js
index 116571ceb9b1..98aeb6a84cf3 100644
--- a/src/applications/pensions/config/chapters/05-financial-information/hasMedicalExpenses.js
+++ b/src/applications/pensions/config/chapters/05-financial-information/hasMedicalExpenses.js
@@ -39,8 +39,8 @@ export const description = (
/** @type {PageSchema} */
export default {
- path: 'financial/medical-expenses',
title: 'Medical expenses and other unreimbursed expenses',
+ path: 'financial/medical-expenses',
uiSchema: {
...titleUI('Medical expenses and other unreimbursed expenses', description),
hasMedicalExpenses: yesNoUI({
diff --git a/src/applications/pensions/config/chapters/05-financial-information/homeAcreageValue.js b/src/applications/pensions/config/chapters/05-financial-information/homeAcreageValue.js
index 54b020c94931..824fd0d12345 100644
--- a/src/applications/pensions/config/chapters/05-financial-information/homeAcreageValue.js
+++ b/src/applications/pensions/config/chapters/05-financial-information/homeAcreageValue.js
@@ -6,6 +6,8 @@ export default {
title: 'Home acreage value',
path: 'financial/home-ownership/acres/value',
depends: isHomeAcreageMoreThanTwo,
+ CustomPage: HomeAcreageValueInput,
+ CustomPageReview: HomeAcreageValueReview,
uiSchema: {},
schema: {
type: 'object',
@@ -15,6 +17,4 @@ export default {
},
},
},
- CustomPage: HomeAcreageValueInput,
- CustomPageReview: HomeAcreageValueReview,
};
diff --git a/src/applications/pensions/config/chapters/05-financial-information/incomeSources.js b/src/applications/pensions/config/chapters/05-financial-information/incomeSources.js
index d98b6d204b42..d56111c454c3 100644
--- a/src/applications/pensions/config/chapters/05-financial-information/incomeSources.js
+++ b/src/applications/pensions/config/chapters/05-financial-information/incomeSources.js
@@ -7,7 +7,6 @@ import {
} from 'platform/forms-system/src/js/web-component-patterns';
import { VaTextInputField } from 'platform/forms-system/src/js/web-component-fields';
import currencyUI from 'platform/forms-system/src/js/definitions/currency';
-
import { IncomeInformationAlert } from '../../../components/FormAlerts';
import {
IncomeSourceDescription,
diff --git a/src/applications/pensions/config/chapters/05-financial-information/landMarketable.js b/src/applications/pensions/config/chapters/05-financial-information/landMarketable.js
index 3c4ff8d5f395..10f0a016b2b8 100644
--- a/src/applications/pensions/config/chapters/05-financial-information/landMarketable.js
+++ b/src/applications/pensions/config/chapters/05-financial-information/landMarketable.js
@@ -4,7 +4,6 @@ import {
yesNoSchema,
yesNoUI,
} from 'platform/forms-system/src/js/web-component-patterns';
-
import {
IncomeAssetStatementFormAlert,
LandMarketableAlert,
diff --git a/src/applications/pensions/config/chapters/05-financial-information/medicalExpenses.js b/src/applications/pensions/config/chapters/05-financial-information/medicalExpenses.js
index 2cdc9c0d3611..7084b89e626d 100644
--- a/src/applications/pensions/config/chapters/05-financial-information/medicalExpenses.js
+++ b/src/applications/pensions/config/chapters/05-financial-information/medicalExpenses.js
@@ -34,8 +34,8 @@ MedicalExpenseView.propTypes = {
/** @type {PageSchema} */
export default {
- path: 'financial/medical-expenses/add',
title: 'Medical expenses and other unreimbursed expenses',
+ path: 'financial/medical-expenses/add',
depends: doesHaveMedicalExpenses,
uiSchema: {
...titleUI('Add a medical or other unreimbursed expense'),
diff --git a/src/applications/pensions/config/chapters/05-financial-information/transferredAssets.js b/src/applications/pensions/config/chapters/05-financial-information/transferredAssets.js
index 911fa96879b6..1ed4b3144582 100644
--- a/src/applications/pensions/config/chapters/05-financial-information/transferredAssets.js
+++ b/src/applications/pensions/config/chapters/05-financial-information/transferredAssets.js
@@ -3,7 +3,6 @@ import {
yesNoSchema,
yesNoUI,
} from 'platform/forms-system/src/js/web-component-patterns';
-
import {
IncomeAssetStatementFormAlert,
AssetTransferInformationAlert,
diff --git a/src/applications/pensions/config/chapters/06-additional-information/documentUpload.js b/src/applications/pensions/config/chapters/06-additional-information/documentUpload.js
index ed6b6bac8253..14f5d92433ec 100644
--- a/src/applications/pensions/config/chapters/06-additional-information/documentUpload.js
+++ b/src/applications/pensions/config/chapters/06-additional-information/documentUpload.js
@@ -1,9 +1,7 @@
import React from 'react';
import { titleUI } from 'platform/forms-system/src/js/web-component-patterns';
-
import environment from 'platform/utilities/environment';
import fileUploadUI from 'platform/forms-system/src/js/definitions/file';
-
import { files } from '../../definitions';
const Description = (
diff --git a/src/applications/pensions/config/chapters/06-additional-information/fasterClaimProcessing.js b/src/applications/pensions/config/chapters/06-additional-information/fasterClaimProcessing.js
index 380dfade2e3d..37c089f23a44 100644
--- a/src/applications/pensions/config/chapters/06-additional-information/fasterClaimProcessing.js
+++ b/src/applications/pensions/config/chapters/06-additional-information/fasterClaimProcessing.js
@@ -7,6 +7,7 @@ import {
const fullyDevelopedClaimsLinkText =
'Learn more about fully developed claims (opens in new tab)';
+
const Description = (
<>
diff --git a/src/applications/pensions/config/chapters/06-additional-information/otherPaymentOptions.js b/src/applications/pensions/config/chapters/06-additional-information/otherPaymentOptions.js
index e0733daf34f8..13f9b13171e3 100644
--- a/src/applications/pensions/config/chapters/06-additional-information/otherPaymentOptions.js
+++ b/src/applications/pensions/config/chapters/06-additional-information/otherPaymentOptions.js
@@ -1,11 +1,13 @@
import { titleUI } from 'platform/forms-system/src/js/web-component-patterns';
import { DirectDepositOtherOptions, usingDirectDeposit } from './helper';
+const notUsingDirectDeposit = formData => !usingDirectDeposit(formData);
+
export default {
title: 'Other payment options',
path: 'additional-information/other-payment-options',
initialData: {},
- depends: formData => !usingDirectDeposit(formData),
+ depends: notUsingDirectDeposit,
uiSchema: {
...titleUI('Other payment options', DirectDepositOtherOptions),
},
diff --git a/src/applications/pensions/config/form.js b/src/applications/pensions/config/form.js
index ea238732dcc9..a0cb743afd95 100644
--- a/src/applications/pensions/config/form.js
+++ b/src/applications/pensions/config/form.js
@@ -2,20 +2,13 @@ import { externalServices } from 'platform/monitoring/DowntimeNotification';
import FormFooter from 'platform/forms/components/FormFooter';
import { VA_FORM_IDS } from 'platform/forms/constants';
import GetFormHelp from '../components/GetFormHelp';
-
-import { submit } from '../helpers';
-
+import { submit } from './submit';
import IntroductionPage from '../components/IntroductionPage';
import ConfirmationPage from '../containers/ConfirmationPage';
import ErrorText from '../components/ErrorText';
-
import migrations from '../migrations';
-
import manifest from '../manifest.json';
-
import { defaultDefinitions } from './definitions';
-
-// chapter-pages
import applicantInformation from './chapters/01-applicant-information';
import militaryHistory from './chapters/02-military-history';
import healthAndEmploymentInformation from './chapters/03-health-and-employment-information';
@@ -24,14 +17,22 @@ import financialInformation from './chapters/05-financial-information';
import additionalInformation from './chapters/06-additional-information';
const formConfig = {
+ formId: VA_FORM_IDS.FORM_21P_527EZ,
+ version: 9,
+ migrations,
rootUrl: manifest.rootUrl,
urlPrefix: '/',
submit,
trackingPrefix: 'pensions-527EZ-',
- introduction: IntroductionPage,
- confirmation: ConfirmationPage,
v3SegmentedProgressBar: true,
- formId: VA_FORM_IDS.FORM_21P_527EZ,
+ prefillEnabled: true,
+ downtime: {
+ dependencies: [externalServices.icmhs],
+ },
+ useCustomScrollAndFocus: false,
+ defaultDefinitions,
+ title: 'Apply for Veterans Pension benefits',
+ subTitle: 'VA Form 21P-527EZ',
saveInProgress: {
messages: {
inProgress: 'Your Veterans pension benefits is in progress.',
@@ -40,24 +41,11 @@ const formConfig = {
saved: 'Your Veterans pension benefits application has been saved.',
},
},
- version: 9,
- migrations,
- prefillEnabled: true,
- // verifyRequiredPrefill: true,
- downtime: {
- dependencies: [externalServices.icmhs],
- },
- // beforeLoad: props => { console.log('form config before load', props); },
- // onFormLoaded: ({ formData, savedForms, returnUrl, formConfig, router }) => {
- // console.log('form loaded', formData, savedForms, returnUrl, formConfig, router);
- // },
savedFormMessages: {
notFound: 'Please start over to apply for pension benefits.',
noAuth:
'Please sign in again to resume your application for pension benefits.',
},
- title: 'Apply for Veterans Pension benefits',
- subTitle: 'VA Form 21P-527EZ',
preSubmitInfo: {
statementOfTruth: {
body:
@@ -67,14 +55,11 @@ const formConfig = {
fullNamePath: 'veteranFullName',
},
},
- // showReviewErrors: true,
- // when true, initial focus on page to H3s by default, and enable page
- // scrollAndFocusTarget (selector string or function to scroll & focus)
- useCustomScrollAndFocus: false,
+ introduction: IntroductionPage,
+ confirmation: ConfirmationPage,
footerContent: FormFooter,
getHelp: GetFormHelp,
errorText: ErrorText,
- defaultDefinitions,
chapters: {
applicantInformation,
militaryHistory,
diff --git a/src/applications/pensions/config/submit.js b/src/applications/pensions/config/submit.js
new file mode 100644
index 000000000000..84828a4b047d
--- /dev/null
+++ b/src/applications/pensions/config/submit.js
@@ -0,0 +1,128 @@
+import * as Sentry from '@sentry/browser';
+import moment from 'moment';
+import environment from 'platform/utilities/environment';
+import { apiRequest } from 'platform/utilities/api';
+import { transformForSubmit } from 'platform/forms-system/src/js/helpers';
+
+const usaPhoneKeys = ['phone', 'mobilePhone', 'dayPhone', 'nightPhone'];
+
+export function replacer(key, value) {
+ if (usaPhoneKeys.includes(key) && value?.length) {
+ // Strip spaces, dashes, and parens from phone numbers
+ return value.replace(/[^\d]/g, '');
+ }
+
+ // clean up empty objects, which we have no reason to send
+ if (typeof value === 'object') {
+ const fields = Object.keys(value);
+ if (
+ fields.length === 0 ||
+ fields.every(field => value[field] === undefined)
+ ) {
+ return undefined;
+ }
+ }
+
+ return value;
+}
+
+function checkStatus(guid) {
+ return apiRequest(`${environment.API_URL}/v0/pension_claims/${guid}`, {
+ mode: 'cors',
+ }).catch(res => {
+ if (res instanceof Error) {
+ Sentry.captureException(res);
+ Sentry.captureMessage('vets_pension_poll_client_error');
+
+ // keep polling because we know they submitted earlier
+ // and this is likely a network error
+ return Promise.resolve();
+ }
+
+ // if we get here, it's likely that we hit a server error
+ return Promise.reject(res);
+ });
+}
+
+const POLLING_INTERVAL = 1000;
+
+function pollStatus(
+ { guid, confirmationNumber, regionalOffice },
+ onDone,
+ onError,
+) {
+ setTimeout(() => {
+ checkStatus(guid)
+ .then(res => {
+ if (!res || res.data.attributes.state === 'pending') {
+ pollStatus(
+ { guid, confirmationNumber, regionalOffice },
+ onDone,
+ onError,
+ );
+ } else if (res.data.attributes.state === 'success') {
+ const response = res.data.attributes.response || {
+ confirmationNumber,
+ regionalOffice,
+ };
+ onDone(response);
+ } else {
+ // needs to start with this string to get the right message on the form
+ throw new Error(
+ `vets_server_error_pensions: status ${res.data.attributes.state}`,
+ );
+ }
+ })
+ .catch(onError);
+ }, window.VetsGov.pollTimeout || POLLING_INTERVAL);
+}
+
+export function transform(formConfig, form) {
+ const formData = transformForSubmit(formConfig, form, replacer);
+ return JSON.stringify({
+ pensionClaim: {
+ form: formData,
+ },
+ // can’t use toISOString because we need the offset
+ localTime: moment().format('Y-MM-DD[T]kk:mm:ssZZ'),
+ });
+}
+
+export function submit(form, formConfig) {
+ const headers = { 'Content-Type': 'application/json' };
+ const body = transform(formConfig, form);
+
+ return apiRequest(`${environment.API_URL}/v0/pension_claims`, {
+ body,
+ headers,
+ method: 'POST',
+ mode: 'cors',
+ })
+ .then(resp => {
+ const { guid, confirmationNumber, regionalOffice } = resp.data.attributes;
+ return new Promise((resolve, reject) => {
+ pollStatus(
+ { guid, confirmationNumber, regionalOffice },
+ response => {
+ window.dataLayer.push({
+ event: `${formConfig.trackingPrefix}-submission-successful`,
+ });
+ return resolve(response);
+ },
+ error => reject(error),
+ );
+ });
+ })
+ .catch(respOrError => {
+ if (respOrError instanceof Response && respOrError.status === 429) {
+ const error = new Error('vets_throttled_error_pensions');
+ error.extra = parseInt(
+ respOrError.headers.get('x-ratelimit-reset'),
+ 10,
+ );
+
+ return Promise.reject(error);
+ }
+ return Promise.reject(respOrError);
+ });
+}
diff --git a/src/applications/pensions/helpers.jsx b/src/applications/pensions/helpers.jsx
index 049777895886..da9cdf604556 100644
--- a/src/applications/pensions/helpers.jsx
+++ b/src/applications/pensions/helpers.jsx
@@ -1,9 +1,5 @@
import React from 'react';
-import * as Sentry from '@sentry/browser';
import moment from 'moment';
-import environment from 'platform/utilities/environment';
-import { apiRequest } from 'platform/utilities/api';
-import { transformForSubmit } from 'platform/forms-system/src/js/helpers';
import Scroll from 'react-scroll';
const { scroller } = Scroll;
@@ -15,130 +11,6 @@ export const scrollToTop = () => {
});
};
-// Includes obsolete 'dayPhone' and 'nightPhone' for stale forms
-const usaPhoneKeys = ['phone', 'mobilePhone', 'dayPhone', 'nightPhone'];
-
-export function replacer(key, value) {
- if (usaPhoneKeys.includes(key) && value?.length) {
- // Strip spaces, dashes, and parens from phone numbers
- return value.replace(/[^\d]/g, '');
- }
-
- // clean up empty objects, which we have no reason to send
- if (typeof value === 'object') {
- const fields = Object.keys(value);
- if (
- fields.length === 0 ||
- fields.every(field => value[field] === undefined)
- ) {
- return undefined;
- }
- }
-
- return value;
-}
-
-function checkStatus(guid) {
- return apiRequest(`${environment.API_URL}/v0/pension_claims/${guid}`, {
- mode: 'cors',
- }).catch(res => {
- if (res instanceof Error) {
- Sentry.captureException(res);
- Sentry.captureMessage('vets_pension_poll_client_error');
-
- // keep polling because we know they submitted earlier
- // and this is likely a network error
- return Promise.resolve();
- }
-
- // if we get here, it's likely that we hit a server error
- return Promise.reject(res);
- });
-}
-
-const POLLING_INTERVAL = 1000;
-
-function pollStatus(
- { guid, confirmationNumber, regionalOffice },
- onDone,
- onError,
-) {
- setTimeout(() => {
- checkStatus(guid)
- .then(res => {
- if (!res || res.data.attributes.state === 'pending') {
- pollStatus(
- { guid, confirmationNumber, regionalOffice },
- onDone,
- onError,
- );
- } else if (res.data.attributes.state === 'success') {
- const response = res.data.attributes.response || {
- confirmationNumber,
- regionalOffice,
- };
- onDone(response);
- } else {
- // needs to start with this string to get the right message on the form
- throw new Error(
- `vets_server_error_pensions: status ${res.data.attributes.state}`,
- );
- }
- })
- .catch(onError);
- }, window.VetsGov.pollTimeout || POLLING_INTERVAL);
-}
-
-export function transform(formConfig, form) {
- const formData = transformForSubmit(formConfig, form, replacer);
- return JSON.stringify({
- pensionClaim: {
- form: formData,
- },
- // can’t use toISOString because we need the offset
- localTime: moment().format('Y-MM-DD[T]kk:mm:ssZZ'),
- });
-}
-
-export function submit(form, formConfig) {
- const headers = { 'Content-Type': 'application/json' };
- const body = transform(formConfig, form);
-
- return apiRequest(`${environment.API_URL}/v0/pension_claims`, {
- body,
- headers,
- method: 'POST',
- mode: 'cors',
- })
- .then(resp => {
- const { guid, confirmationNumber, regionalOffice } = resp.data.attributes;
- return new Promise((resolve, reject) => {
- pollStatus(
- { guid, confirmationNumber, regionalOffice },
- response => {
- window.dataLayer.push({
- event: `${formConfig.trackingPrefix}-submission-successful`,
- });
- return resolve(response);
- },
- error => reject(error),
- );
- });
- })
- .catch(respOrError => {
- if (respOrError instanceof Response && respOrError.status === 429) {
- const error = new Error('vets_throttled_error_pensions');
- error.extra = parseInt(
- respOrError.headers.get('x-ratelimit-reset'),
- 10,
- );
-
- return Promise.reject(error);
- }
- return Promise.reject(respOrError);
- });
-}
-
export const formatCurrency = num => `$${num.toLocaleString()}`;
const warDates = [
diff --git a/src/applications/pensions/tests/unit/chapters/03-health-and-employment-information/employmentHistory.unit.spec.jsx b/src/applications/pensions/tests/unit/chapters/03-health-and-employment-information/employmentHistory.unit.spec.jsx
index 2c171e74dd27..e9e06479f0d3 100644
--- a/src/applications/pensions/tests/unit/chapters/03-health-and-employment-information/employmentHistory.unit.spec.jsx
+++ b/src/applications/pensions/tests/unit/chapters/03-health-and-employment-information/employmentHistory.unit.spec.jsx
@@ -7,9 +7,10 @@ import {
testNumberOfWebComponentFields,
} from '../pageTests.spec';
import formConfig from '../../../../config/form';
-import generateEmployersSchemas, {
+import {
+ generateEmployersSchemas,
EmployerView,
-} from '../../../../config/chapters/03-health-and-employment-information/employmentHistory';
+} from '../../../../config/chapters/03-health-and-employment-information/helpers';
const { schema, uiSchema } = generateEmployersSchemas({
showJobTitleField: true,
diff --git a/src/applications/pensions/tests/unit/chapters/03-health-and-employment-information/treatmentHistory.unit.spec.jsx b/src/applications/pensions/tests/unit/chapters/03-health-and-employment-information/treatmentHistory.unit.spec.jsx
index 8a628a72f061..851c2ad45d3f 100644
--- a/src/applications/pensions/tests/unit/chapters/03-health-and-employment-information/treatmentHistory.unit.spec.jsx
+++ b/src/applications/pensions/tests/unit/chapters/03-health-and-employment-information/treatmentHistory.unit.spec.jsx
@@ -4,7 +4,7 @@ import {
} from '../pageTests.spec';
import formConfig from '../../../../config/form';
import treatmentHistory from '../../../../config/chapters/03-health-and-employment-information/vaTreatmentHistory';
-import generateMedicalCentersSchemas from '../../../../config/chapters/03-health-and-employment-information/medicalCenters';
+import { generateMedicalCentersSchemas } from '../../../../config/chapters/03-health-and-employment-information/helpers';
describe('pension treatment history page', () => {
const pageTitle = 'treatment history';
diff --git a/src/applications/pensions/tests/unit/config/form.unit.spec.jsx b/src/applications/pensions/tests/unit/config/form.unit.spec.jsx
index 982d42ff3ee9..7145cce643bf 100644
--- a/src/applications/pensions/tests/unit/config/form.unit.spec.jsx
+++ b/src/applications/pensions/tests/unit/config/form.unit.spec.jsx
@@ -3,7 +3,7 @@ import { expect } from 'chai';
import formConfig from '../../../config/form';
-import { transform } from '../../../helpers';
+import { transform } from '../../../config/submit';
import overflowForm from '../../e2e/fixtures/data/overflow-test.json';
import {
hasFederalTreatmentHistory,
diff --git a/src/applications/pensions/tests/unit/helpers.unit.spec.jsx b/src/applications/pensions/tests/unit/helpers.unit.spec.jsx
index b56e8afe91b7..3e319648a550 100644
--- a/src/applications/pensions/tests/unit/helpers.unit.spec.jsx
+++ b/src/applications/pensions/tests/unit/helpers.unit.spec.jsx
@@ -6,16 +6,12 @@ import {
setFetchJSONResponse as setFetchResponse,
} from 'platform/testing/unit/helpers';
import { transformForSubmit } from 'platform/forms-system/src/js/helpers';
-import {
- formatCurrency,
- submit,
- replacer,
- isHomeAcreageMoreThanTwo,
-} from '../../helpers';
+import { formatCurrency, isHomeAcreageMoreThanTwo } from '../../helpers';
import {
getMarriageTitleWithCurrent,
isMarried,
} from '../../config/chapters/04-household-information/helpers';
+import { replacer, submit } from '../../config/submit';
describe('Pensions helpers', () => {
describe('submit', () => {