Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10-10EZ | Upgrade performance for presubmit components #35117

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React from 'react';

const NoticeAgreement = () => (
<>
<h3>Agreement</h3>
<p>By submitting this application, you agree to these statements:</p>
<ul data-testid="hca-agreement-statements">
<li>
You’ll pay any VA copays for care or services (including urgent care)
that may apply, based on your priority group and other factors.
</li>
<li>
You agree that we can contact you at the email, home phone number, and
mobile phone number you gave us in the application.
</li>
<li>
You agree to the assignment of benefits so we can bill your other health
insurance or other responsible party for charges of nonservice-connected
VA medical care or services.
</li>
<li>
You’ve read and accept our privacy policy.{' '}
<span className="vads-u-display--block">
<a target="_blank" href="/privacy-policy/">
Read our privacy policy
<span className="vads-u-visibility--screen-reader">
, will open in new tab
</span>
</a>
</span>
</li>
</ul>
<va-additional-info
trigger="Read more about the assignment of benefits"
class="vads-u-margin-y--2"
>
<p>
I understand that pursuant to 38 U.S.C. Section 1729 and 42 U.S.C. 2651,
the Department of Veterans Affairs (VA) is authorized to recover or
collect from my health plan (HP) or any other legally responsible third
party for the reasonable charges of nonservice-connected VA medical care
or services furnished or provided to me. I hereby authorize payment
directly to VA from any HP under which I am covered (including coverage
provided under my spouse’s HP) that is responsible for payment of the
charges for my medical care, including benefits otherwise payable to me
or my spouse. Furthermore, I hereby assign to the VA any claim I may
have against any person or entity who is or may be legally responsible
for the payment of the cost of medical services provided to me by the
VA. I understand that this assignment shall not limit or prejudice my
right to recover for my own benefit any amount in excess of the cost of
medical services provided to me by the VA or any other amount to which I
may be entitled. I hereby appoint the Attorney General of the United
States and the Secretary of Veterans' Affairs and their designees as my
Attorneys-in-fact to take all necessary and appropriate actions in order
to recover and receive all or part of the amount herein assigned. I
hereby authorize the VA to disclose, to my attorney and to any third
party or administrative agency who may be responsible for payment of the
cost of medical services provided to me, information from my medical
records as necessary to verify my claim. Further, I hereby authorize any
such third party or administrative agency to disclose to the VA any
information regarding my claim.
</p>
</va-additional-info>
<p>
<strong>Note:</strong> According to federal law, there are criminal
penalties, including a fine and/or imprisonment for up to 5 years, for
withholding information or for providing incorrect information. (See 18
U.S.C. 1001)
</p>
</>
);

export default NoticeAgreement;
133 changes: 29 additions & 104 deletions src/applications/hca/components/PreSubmitNotice/index.jsx
Original file line number Diff line number Diff line change
@@ -1,137 +1,62 @@
import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import { REACT_BINDINGS } from '../../utils/imports';
import content from '../../locales/en/content.json';
import NoticeAgreement from './NoticeAgreement';

// expose React binding for web components
const { VaCheckbox } = REACT_BINDINGS;

const PreSubmitNotice = props => {
const { preSubmitInfo, showError, onSectionComplete, submission } = props;
const PreSubmitNotice = ({ preSubmitInfo, showError, onSectionComplete }) => {
const formSubmitted = !!useSelector(state => state.form.submission.status);
const { field, required } = preSubmitInfo;

const [accepted, setAccepted] = useState(false);
const [error, setError] = useState(undefined);
const formSubmitted = !!submission.status;

// set section complete value--unset if user navigates away from the page before submitting the form.
useEffect(
() => {
onSectionComplete(accepted);
const onVaCheckboxChange = useCallback(
event => setAccepted(event.target.checked),
[],
);

return () => {
onSectionComplete(false);
};
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[accepted],
const error = useMemo(
() =>
accepted || formSubmitted || !showError
? null
: content['presubmit--error-message'],
[accepted, formSubmitted, showError],
);

// set error message status
useEffect(
() => {
const hasError = accepted === true || formSubmitted ? false : showError;
const message = hasError
? 'You must accept the agreement before continuing.'
: undefined;
setError(message);
onSectionComplete(accepted);
return () => onSectionComplete(false);
},
[accepted, showError, formSubmitted],
// eslint-disable-next-line react-hooks/exhaustive-deps
[accepted],
);

return (
<>
<h3>Agreement</h3>
<p>By submitting this application, you agree to these statements:</p>
<ul data-testid="hca-agreement-statements">
<li>
You’ll pay any VA copays for care or services (including urgent care)
that may apply, based on your priority group and other factors.
</li>
<li>
You agree that we can contact you at the email, home phone number, and
mobile phone number you gave us in the application.
</li>
<li>
You agree to the assignment of benefits so we can bill your other
health insurance or other responsible party for charges of
nonservice-connected VA medical care or services.
</li>
<li>
You’ve read and accept our privacy policy.{' '}
<span className="vads-u-display--block">
<a target="_blank" href="/privacy-policy/">
Read our privacy policy
<span className="vads-u-visibility--screen-reader">
, will open in new tab
</span>
</a>
</span>
</li>
</ul>
<va-additional-info
trigger="Read more about the assignment of benefits"
class="vads-u-margin-y--2"
uswds
>
<p>
I understand that pursuant to 38 U.S.C. Section 1729 and 42 U.S.C.
2651, the Department of Veterans Affairs (VA) is authorized to recover
or collect from my health plan (HP) or any other legally responsible
third party for the reasonable charges of nonservice-connected VA
medical care or services furnished or provided to me. I hereby
authorize payment directly to VA from any HP under which I am covered
(including coverage provided under my spouse’s HP) that is responsible
for payment of the charges for my medical care, including benefits
otherwise payable to me or my spouse. Furthermore, I hereby assign to
the VA any claim I may have against any person or entity who is or may
be legally responsible for the payment of the cost of medical services
provided to me by the VA. I understand that this assignment shall not
limit or prejudice my right to recover for my own benefit any amount
in excess of the cost of medical services provided to me by the VA or
any other amount to which I may be entitled. I hereby appoint the
Attorney General of the United States and the Secretary of Veterans'
Affairs and their designees as my Attorneys-in-fact to take all
necessary and appropriate actions in order to recover and receive all
or part of the amount herein assigned. I hereby authorize the VA to
disclose, to my attorney and to any third party or administrative
agency who may be responsible for payment of the cost of medical
services provided to me, information from my medical records as
necessary to verify my claim. Further, I hereby authorize any such
third party or administrative agency to disclose to the VA any
information regarding my claim.
</p>
</va-additional-info>
<p>
<strong>Note:</strong> According to federal law, there are criminal
penalties, including a fine and/or imprisonment for up to 5 years, for
withholding information or for providing incorrect information. (See 18
U.S.C. 1001)
</p>
<NoticeAgreement />
<VaCheckbox
required={required}
name={field}
label={content['presubmit--checkbox-label']}
onVaChange={onVaCheckboxChange}
error={error}
onVaChange={event => setAccepted(event.target.checked)}
label="I confirm that I agree to the statements listed here. The information is true and correct to the best of my knowledge and belief. I’ve read and accept the privacy policy."
uswds
required={required}
/>
</>
);
};

PreSubmitNotice.propTypes = {
formData: PropTypes.object,
preSubmitInfo: PropTypes.object,
preSubmitInfo: PropTypes.shape({
field: PropTypes.string,
required: PropTypes.bool,
}),
showError: PropTypes.bool,
submission: PropTypes.object,
onSectionComplete: PropTypes.func,
};

const mapStateToProps = state => {
return {
submission: state.form.submission,
};
};

export default connect(mapStateToProps)(PreSubmitNotice);
export default PreSubmitNotice;
2 changes: 2 additions & 0 deletions src/applications/hca/locales/en/content.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"load-enrollment-status": "Verifying your enrollment status...",
"page-title--before-you-begin": "Before you start your application",
"page-title--check-your-information": "Check your personal information",
"presubmit--error-message": "You must accept the agreement before continuing.",
"presubmit--checkbox-label": "I confirm that I agree to the statements listed here. The information is true and correct to the best of my knowledge and belief. I\u2019ve read and accept the privacy policy.",
"sip-start-form-text": "Start the health care application",
"vet-info--birthplace-title": "Your place of birth",
"vet-info--birthplace-description": "Enter your place of birth, including city and state, province or region.",
Expand Down
Loading