-
Notifications
You must be signed in to change notification settings - Fork 125
/
servicePeriod.js
87 lines (82 loc) · 2.79 KB
/
servicePeriod.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
import fullSchemaPensions from 'vets-json-schema/dist/21P-527EZ-schema.json';
import { createSelector } from 'reselect';
import { isFullDate } from 'platform/forms/validations';
import {
currentOrPastDateRangeUI,
currentOrPastDateRangeSchema,
serviceNumberUI,
serviceNumberSchema,
checkboxGroupUI,
checkboxGroupSchema,
titleUI,
} from 'platform/forms-system/src/js/web-component-patterns';
import { VaTextInputField } from 'platform/forms-system/src/js/web-component-fields';
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 {
title: 'Service period',
path: 'military/history',
CustomPageReview: ServicePeriodReview,
uiSchema: {
...titleUI('Service period'),
serviceBranch: checkboxGroupUI({
title: 'Branch of service',
labels: serviceBranchLabels,
required: true,
}),
activeServiceDateRange: currentOrPastDateRangeUI(
'Date initially entered active duty',
'Final release date from active duty',
'Date initially entered active duty must be before final date released from active duty',
),
serviceNumber: serviceNumberUI('Military Service number if you have one'),
placeOfSeparation: {
'ui:title': 'Place of your last separation',
'ui:options': {
hint: 'City and state or foreign country',
},
'ui:webComponentField': VaTextInputField,
},
'ui:validations': [validateServiceBirthDates],
'view:wartimeWarning': (() => {
const hideWartimeWarning = createSelector(
form => form.activeServiceDateRange,
activeServiceDateRange => {
const completePeriod =
activeServiceDateRange &&
isFullDate(activeServiceDateRange.to) &&
isFullDate(activeServiceDateRange.from);
if (!completePeriod) {
return true;
}
return servedDuringWartime(activeServiceDateRange);
},
);
return {
'ui:description': WartimeWarningAlert,
'ui:options': {
hideIf: hideWartimeWarning,
},
};
})(),
},
schema: {
type: 'object',
required: ['serviceBranch', 'activeServiceDateRange'],
properties: {
serviceBranch: checkboxGroupSchema(Object.keys(serviceBranchLabels)),
activeServiceDateRange: currentOrPastDateRangeSchema,
serviceNumber: serviceNumberSchema,
placeOfSeparation,
'view:wartimeWarning': {
type: 'object',
properties: {},
},
},
},
};