This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathPreSubmitInfo2.jsx
More file actions
64 lines (58 loc) · 2.07 KB
/
PreSubmitInfo2.jsx
File metadata and controls
64 lines (58 loc) · 2.07 KB
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
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { VaStatementOfTruth } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import {
statementOfTruthBodyElement,
statementOfTruthFullName,
fullNameReducer,
} from 'platform/forms/components/review/PreSubmitSection';
const STATEMENT_OF_TRUTH = {
body:
'I confirm that the identifying information in this form is accurate and has been represented correctly.',
fullNamePath: 'fullName',
useProfileFullName: true,
};
export const PreSubmitInfo2 = ({ formData, showError, onSectionComplete }) => {
const [signature, setSignature] = useState('');
const [certified, setCertified] = useState(false);
const [signatureBlurred, setSignatureBlurred] = useState(false);
const expectedFullName = statementOfTruthFullName(
formData,
STATEMENT_OF_TRUTH,
);
const signatureMismatch =
fullNameReducer(signature) !== fullNameReducer(expectedFullName);
return (
<VaStatementOfTruth
heading="Certification and Signature"
inputLabel="Your full name"
inputValue={signature}
inputMessageAriaDescribedby={`Statement of truth: ${STATEMENT_OF_TRUTH.messageAriaDescribedby ||
''}`}
inputError={
(showError || signatureBlurred) && signatureMismatch
? `Please enter your name exactly as it appears on your application: ${expectedFullName}`
: undefined
}
checked={certified}
onVaInputChange={event => setSignature(event.detail.value)}
onVaInputBlur={() => setSignatureBlurred(true)}
onVaCheckboxChange={event => {
setCertified(event.detail.checked);
onSectionComplete(event.detail.checked);
}}
checkboxError={
showError && !certified
? 'You must certify by checking the box'
: undefined
}
>
{statementOfTruthBodyElement(formData, STATEMENT_OF_TRUTH.body)}
</VaStatementOfTruth>
);
};
PreSubmitInfo2.propTypes = {
formData: PropTypes.object,
onSectionComplete: PropTypes.func,
showError: PropTypes.bool,
};