-
Notifications
You must be signed in to change notification settings - Fork 125
/
form.js
589 lines (576 loc) · 19.1 KB
/
form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
import _ from 'lodash/fp';
import moment from 'moment';
import fullSchema1990 from 'vets-json-schema/dist/22-1990-schema.json';
import contactInformationPage from '../../pages/contactInformation';
import applicantInformation from '../../../../platform/forms/pages/applicantInformation';
import GetFormHelp from '../../components/GetFormHelp';
import ErrorText from '../../components/ErrorText';
import createSchoolSelectionPage from '../../pages/schoolSelection';
import dateRangeUI from 'us-forms-system/lib/js/definitions/dateRange';
import {
schema as addressSchema,
uiSchema as addressUI,
} from '../../../../platform/forms/definitions/address';
import phoneUI from 'us-forms-system/lib/js/definitions/phone';
import FormFooter from '../../../../platform/forms/components/FormFooter';
import environment from '../../../../platform/utilities/environment';
import preSubmitInfo from '../../../../platform/forms/preSubmitInfo';
import seniorRotcUI from '../../definitions/seniorRotc';
import employmentHistoryPage from '../../pages/employmentHistory';
import createDirectDepositPage from '../../pages/directDeposit';
import postHighSchoolTrainingsUI from '../../definitions/postHighSchoolTrainings';
import currentOrPastMonthYearUI from 'us-forms-system/lib/js/definitions/currentOrPastMonthYear';
import yearUI from 'us-forms-system/lib/js/definitions/year';
import * as toursOfDuty from '../../definitions/toursOfDuty';
import serviceBefore1977UI from '../../definitions/serviceBefore1977';
import IntroductionPage from '../containers/IntroductionPage';
import ConfirmationPage from '../containers/ConfirmationPage';
import BenefitsRelinquishmentField from '../BenefitsRelinquishmentField';
import { validateBooleanGroup } from 'us-forms-system/lib/js/validation';
import dateUI from 'us-forms-system/lib/js/definitions/date';
import {
transform,
benefitsEligibilityBox,
benefitsRelinquishmentWarning,
benefitsRelinquishmentLabels,
benefitsRelinquishedDescription,
directDepositDescription,
prefillTransformer,
reserveKickerWarning,
} from '../helpers';
import { urlMigration } from '../../config/migrations';
import { hasServiceBefore1977 } from '../../utils/helpers.jsx';
import { benefitsLabels } from '../../utils/labels';
const {
chapter33,
chapter30,
chapter1606,
chapter32,
seniorRotcScholarshipProgram,
seniorRotc,
civilianBenefitsAssistance,
additionalContributions,
activeDutyKicker,
reserveKicker,
benefitsRelinquished,
benefitsRelinquishedDate,
faaFlightCertificatesInformation,
highSchoolOrGedCompletionDate,
serviceAcademyGraduationYear,
secondaryContact,
} = fullSchema1990.properties;
const {
postHighSchoolTrainings,
date,
dateRange,
year,
currentlyActiveDuty,
address,
phone,
serviceBefore1977,
} = fullSchema1990.definitions;
const formConfig = {
urlPrefix: '/',
submitUrl: `${environment.API_URL}/v0/education_benefits_claims/1990`,
trackingPrefix: 'edu-',
formId: '22-1990',
version: 1,
migrations: [urlMigration('/1990')],
savedFormMessages: {
notFound: 'Please start over to apply for education benefits.',
noAuth:
'Please sign in again to resume your application for education benefits.',
},
prefillEnabled: true,
prefillTransformer,
transformForSubmit: transform,
introduction: IntroductionPage,
confirmation: ConfirmationPage,
defaultDefinitions: {
date,
dateRange,
year,
address,
phone,
serviceBefore1977,
},
title: 'Apply for education benefits',
subTitle: 'Form 22-1990',
preSubmitInfo,
footerContent: FormFooter,
getHelp: GetFormHelp,
errorText: ErrorText,
chapters: {
applicantInformation: {
title: 'Applicant Information',
pages: {
applicantInformation: _.merge(
applicantInformation(fullSchema1990, {
isVeteran: true,
fields: [
'veteranFullName',
'veteranSocialSecurityNumber',
'veteranDateOfBirth',
'gender',
],
required: [
'veteranFullName',
'veteranSocialSecurityNumber',
'veteranDateOfBirth',
],
}),
{
uiSchema: {
veteranDateOfBirth: {
'ui:validations': [
(errors, dob) => {
// If we have a complete date, check to make sure it’s a valid dob
if (
/\d{4}-\d{2}-\d{2}/.test(dob) &&
moment(dob).isAfter(
moment()
.endOf('day')
.subtract(17, 'years'),
)
) {
errors.addError('You must be at least 17 to apply');
}
},
],
},
},
},
),
},
},
benefitsEligibility: {
title: 'Benefits Eligibility',
pages: {
benefitsEligibility: {
title: 'Benefits eligibility',
path: 'benefits-eligibility/benefits-selection',
uiSchema: {
'ui:description': benefitsEligibilityBox,
'view:selectedBenefits': {
'ui:title': 'Select the benefit that is the best match for you.',
'ui:validations': [validateBooleanGroup],
'ui:errorMessages': {
atLeastOne: 'Please select at least one benefit',
},
'ui:options': {
showFieldLabel: true,
},
chapter33: {
'ui:title': benefitsLabels.chapter33,
'ui:options': {
expandUnderClassNames: 'schemaform-expandUnder-indent',
},
},
'view:chapter33ExpandedContent': {
'ui:description':
'When you choose to apply for your Post-9/11 benefit, you have to relinquish (give up) 1 other benefit you may be eligible for. You’ll make this decision on the next page.',
'ui:options': {
expandUnder: 'chapter33',
},
},
chapter30: {
'ui:title': benefitsLabels.chapter30,
},
chapter1606: {
'ui:title': benefitsLabels.chapter1606,
},
chapter32: {
'ui:title': benefitsLabels.chapter32,
},
},
},
schema: {
type: 'object',
required: ['view:selectedBenefits'],
properties: {
'view:selectedBenefits': {
type: 'object',
properties: {
chapter33,
'view:chapter33ExpandedContent': {
type: 'object',
properties: {},
},
chapter30,
chapter1606,
chapter32,
},
},
},
},
},
benefitsRelinquishment: {
title: 'Benefits relinquishment',
path: 'benefits-eligibility/benefits-relinquishment',
depends: formData => formData['view:selectedBenefits'].chapter33,
initialData: {
'view:benefitsRelinquishedContainer': {
benefitsRelinquishedDate: moment().format('YYYY-MM-DD'),
},
},
uiSchema: {
'ui:title': 'Benefits relinquishment',
'ui:description': benefitsRelinquishmentWarning,
'view:benefitsRelinquishedContainer': {
'ui:field': BenefitsRelinquishmentField,
benefitsRelinquished: {
'ui:title': 'I choose to give up:',
'ui:widget': 'radio',
'ui:options': {
labels: benefitsRelinquishmentLabels,
},
},
benefitsRelinquishedDate: _.merge(dateUI('Effective date'), {
'ui:required': formData =>
_.get(
'view:benefitsRelinquishedContainer.benefitsRelinquished',
formData,
) !== 'unknown',
}),
},
'view:questionText': {
'ui:description': benefitsRelinquishedDescription,
},
},
schema: {
type: 'object',
properties: {
'view:benefitsRelinquishedContainer': {
type: 'object',
required: ['benefitsRelinquished'],
properties: {
benefitsRelinquished,
benefitsRelinquishedDate,
},
},
'view:questionText': {
type: 'object',
properties: {},
},
},
},
},
},
},
militaryHistory: {
title: 'Military History',
pages: {
servicePeriods: {
title: 'Service periods',
path: 'military-history/service-periods',
uiSchema: {
'ui:title': 'Service periods',
toursOfDuty: _.merge(toursOfDuty.uiSchema, {
'ui:title': null,
'ui:description': 'Please record all your periods of service.',
}),
},
schema: {
type: 'object',
properties: {
toursOfDuty: toursOfDuty.schema(fullSchema1990, {
required: ['serviceBranch', 'dateRange.from'],
fields: [
'serviceBranch',
'serviceStatus',
'dateRange',
'applyPeriodToSelected',
'benefitsToApplyTo',
'view:disclaimer',
],
}),
},
},
},
militaryService: {
title: 'Military service',
path: 'military-history/military-service',
uiSchema: {
serviceAcademyGraduationYear: _.assign(yearUI, {
'ui:title':
'If you received a commission from a military service academy, what year did you graduate?',
}),
currentlyActiveDuty: {
yes: {
'ui:title': 'Are you on active duty now?',
'ui:widget': 'yesNo',
},
onTerminalLeave: {
'ui:title': 'Are you on terminal leave now?',
'ui:widget': 'yesNo',
'ui:options': {
expandUnder: 'yes',
},
},
},
},
schema: {
type: 'object',
properties: {
serviceAcademyGraduationYear,
currentlyActiveDuty: {
type: 'object',
properties: {
yes: currentlyActiveDuty.properties.yes,
onTerminalLeave:
currentlyActiveDuty.properties.onTerminalLeave,
},
},
},
},
},
rotcHistory: {
title: 'ROTC history',
path: 'military-history/rotc-history',
uiSchema: {
'ui:title': 'ROTC history',
seniorRotcScholarshipProgram: {
'ui:title':
'Are you in a senior ROTC scholarship program right now that pays your tuition, fees, books, and supplies? (Covered under Section 2107 of Title 10, U.S. Code)',
'ui:widget': 'yesNo',
},
'view:seniorRotc': {
'ui:title': 'Were you commissioned as a result of senior ROTC?',
'ui:widget': 'yesNo',
},
seniorRotc: {
commissionYear: _.merge(yearUI, {
'ui:title': 'Year of commission:',
}),
rotcScholarshipAmounts: seniorRotcUI,
'ui:options': {
expandUnder: 'view:seniorRotc',
},
},
},
schema: {
type: 'object',
properties: {
seniorRotcScholarshipProgram,
'view:seniorRotc': {
type: 'boolean',
},
seniorRotc: _.unset('required', seniorRotc),
},
},
},
contributions: {
title: 'Contributions',
path: 'military-history/contributions',
uiSchema: {
'ui:title': 'Contributions',
'ui:description': 'Select all that apply:',
civilianBenefitsAssistance: {
'ui:title':
'I am receiving benefits from the U.S. Government as a civilian employee during the same time as I am seeking benefits from VA.',
},
additionalContributions: {
'ui:title':
'I made contributions (up to $600) to increase the amount of my monthly benefits.',
},
activeDutyKicker: {
'ui:title':
'I qualify for an Active Duty Kicker (sometimes called a college fund).',
},
reserveKicker: {
'ui:title':
'I qualify for a Reserve Kicker (sometimes called a college fund).',
},
'view:reserveKickerWarning': {
'ui:description': reserveKickerWarning,
'ui:options': {
expandUnder: 'reserveKicker',
hideIf: data =>
_.get(
'view:benefitsRelinquishedContainer.benefitsRelinquished',
data,
) !== 'chapter30',
},
},
'view:activeDutyRepayingPeriod': {
'ui:title':
'I have a period of service that the Department of Defense counts toward an education loan payment.',
'ui:options': {
expandUnderClassNames: 'schemaform-expandUnder-indent',
},
},
activeDutyRepayingPeriod: _.merge(
{
'ui:options': {
expandUnder: 'view:activeDutyRepayingPeriod',
},
to: {
'ui:required': formData =>
formData['view:activeDutyRepayingPeriod'],
},
from: {
'ui:required': formData =>
formData['view:activeDutyRepayingPeriod'],
},
},
dateRangeUI('Start date', 'End date'),
),
},
schema: {
type: 'object',
properties: {
civilianBenefitsAssistance,
additionalContributions,
activeDutyKicker,
reserveKicker,
'view:reserveKickerWarning': {
type: 'object',
properties: {},
},
'view:activeDutyRepayingPeriod': {
type: 'boolean',
},
activeDutyRepayingPeriod: dateRange,
},
},
},
},
},
educationHistory: {
title: 'Education History',
pages: {
educationHistory: {
title: 'Education history',
// There’s only one page in this chapter (right?), so this url seems a
// bit heavy-handed.
path: 'education-history/education-information',
uiSchema: {
highSchoolOrGedCompletionDate: currentOrPastMonthYearUI(
'When did you earn your high school diploma or equivalency certificate?',
),
postHighSchoolTrainings: postHighSchoolTrainingsUI,
faaFlightCertificatesInformation: {
'ui:title':
'If you have any FAA flight certificates, please list them here.',
'ui:widget': 'textarea',
},
},
schema: {
type: 'object',
properties: {
highSchoolOrGedCompletionDate,
postHighSchoolTrainings,
faaFlightCertificatesInformation,
},
},
},
},
},
employmentHistory: {
title: 'Employment History',
pages: {
employmentHistory: _.merge(employmentHistoryPage(fullSchema1990), {
path: 'employment-history/employment-information',
}),
},
},
schoolSelection: {
title: 'School Selection',
pages: {
schoolSelection: _.merge(
createSchoolSelectionPage(fullSchema1990, {
fields: [
'educationProgram',
'educationObjective',
'educationStartDate',
'currentlyActiveDuty',
],
required: ['educationType'],
}),
{
path: 'school-selection/school-information',
},
),
},
},
personalInformation: {
title: 'Personal Information',
pages: {
contactInformation: _.merge(contactInformationPage(fullSchema1990), {
uiSchema: {
'ui:title': 'Contact information',
},
}),
secondaryContact: {
title: 'Secondary contact',
path: 'personal-information/secondary-contact',
uiSchema: {
'ui:title': 'Secondary contact',
'ui:description':
'This person should know where you can be reached at all times.',
secondaryContact: {
fullName: {
'ui:title': 'Name',
},
phone: phoneUI('Telephone number'),
'view:address': {
'ui:title': 'Address',
sameAddress: {
'ui:title':
'Address for secondary contact is the same as mine',
},
address: _.merge(addressUI('', false), {
'ui:options': {
hideIf: formData =>
formData.secondaryContact &&
formData.secondaryContact['view:address'].sameAddress,
},
}),
},
},
},
schema: {
type: 'object',
properties: {
secondaryContact: {
type: 'object',
properties: {
fullName: secondaryContact.properties.fullName,
phone,
'view:address': {
type: 'object',
properties: {
sameAddress: secondaryContact.properties.sameAddress,
address: addressSchema(fullSchema1990),
},
},
},
},
},
},
},
dependents: {
title: 'Dependent information',
path: 'personal-information/dependents',
depends: hasServiceBefore1977,
uiSchema: {
'ui:title': 'Dependents',
serviceBefore1977: serviceBefore1977UI,
},
schema: {
type: 'object',
properties: {
serviceBefore1977,
},
},
},
directDeposit: _.merge(createDirectDepositPage(fullSchema1990), {
uiSchema: {
'ui:description': directDepositDescription,
},
}),
},
},
},
};
export default formConfig;