diff --git a/src/applications/benefit-eligibility-questionnaire/containers/ConfirmationPage.jsx b/src/applications/benefit-eligibility-questionnaire/containers/ConfirmationPage.jsx
index fc675001daef..0bde7a155704 100644
--- a/src/applications/benefit-eligibility-questionnaire/containers/ConfirmationPage.jsx
+++ b/src/applications/benefit-eligibility-questionnaire/containers/ConfirmationPage.jsx
@@ -121,6 +121,7 @@ export class ConfirmationPage extends React.Component {
if (key === 'All') {
this.setState(() => ({
benefits: this.props.results.data,
+ resultsCount: this.props.results.data.length,
}));
return;
}
diff --git a/src/applications/combined-debt-portal/combined/tests/unit/combinedHelpers.unit.spec.js b/src/applications/combined-debt-portal/combined/tests/unit/combinedHelpers.unit.spec.js
index 103340db529f..406f08f5516b 100644
--- a/src/applications/combined-debt-portal/combined/tests/unit/combinedHelpers.unit.spec.js
+++ b/src/applications/combined-debt-portal/combined/tests/unit/combinedHelpers.unit.spec.js
@@ -1,5 +1,5 @@
import { expect } from 'chai';
-import moment from 'moment';
+import { addMonths, subMonths } from 'date-fns';
import { getMedicalCenterNameByID } from 'platform/utilities/medical-centers/medical-centers';
import {
APP_TYPES,
@@ -12,6 +12,7 @@ import {
verifyCurrentBalance,
transform,
setPageFocus,
+ formatDate,
} from '../../utils/helpers';
describe('Helper Functions', () => {
@@ -68,18 +69,33 @@ describe('Helper Functions', () => {
});
});
+ describe('formatDate - expected output example: October 13, 2018', () => {
+ const expectedResult = 'October 13, 2018';
+
+ it("should return correctly formatted date from string that uses '/' delimiter", () => {
+ const simpleDate = '10/13/2018';
+ expect(formatDate(simpleDate)).to.equal(expectedResult);
+ });
+
+ it("should return correctly formatted date from string that has '-' delimiter", () => {
+ const simpleDate = '10-13-2018';
+ expect(formatDate(simpleDate)).to.equal(expectedResult);
+ });
+
+ it('should return correctly formatted date from string from new date object', () => {
+ const simpleDate = new Date('10/13/2018');
+ expect(formatDate(simpleDate)).to.equal(expectedResult);
+ });
+ });
+
describe('verifyCurrentBalance', () => {
it('should return true if current date is on or before due date', () => {
- const futureDate = moment()
- .add(1, 'month')
- .format('MM-DD-YYYY');
+ const futureDate = addMonths(new Date(), 1);
expect(verifyCurrentBalance(futureDate)).to.be.true;
});
it('should return false if current date is after due date', () => {
- const pastDate = moment()
- .subtract(1, 'month')
- .format('MM-DD-YYYY');
+ const pastDate = subMonths(new Date(), 1);
expect(verifyCurrentBalance(pastDate)).to.be.false;
});
});
diff --git a/src/applications/combined-debt-portal/combined/utils/helpers.js b/src/applications/combined-debt-portal/combined/utils/helpers.js
index aa0e243f9b82..a250ce21131d 100644
--- a/src/applications/combined-debt-portal/combined/utils/helpers.js
+++ b/src/applications/combined-debt-portal/combined/utils/helpers.js
@@ -1,8 +1,7 @@
import FEATURE_FLAG_NAMES from 'platform/utilities/feature-toggles/featureFlagNames';
import { toggleValues } from 'platform/site-wide/feature-toggles/selectors';
-import { format } from 'date-fns';
+import { addDays, format, isBefore, isEqual, isValid } from 'date-fns';
import { getMedicalCenterNameByID } from 'platform/utilities/medical-centers/medical-centers';
-import moment from 'moment';
import React from 'react';
export const APP_TYPES = Object.freeze({
@@ -33,8 +32,17 @@ export const showPaymentHistory = state =>
export const selectLoadingFeatureFlags = state =>
state?.featureToggles?.loading;
+/**
+ * Helper function to consisently format date strings
+ *
+ * @param {string} date - date string or date type
+ * @returns formatted date string; example:
+ * - January 1, 2021
+ */
export const formatDate = date => {
- return format(new Date(date), 'MMMM d, yyyy');
+ const newDate =
+ typeof date === 'string' ? new Date(date.replace(/-/g, '/')) : date;
+ return isValid(newDate) ? format(new Date(newDate), 'MMMM d, y') : '';
};
export const currency = amount => {
@@ -57,9 +65,7 @@ export const formatTableData = tableData =>
}));
export const calcDueDate = (date, days) => {
- return moment(date, 'MM-DD-YYYY')
- .add(days, 'days')
- .format('MMMM D, YYYY');
+ return formatDate(addDays(new Date(date), days));
};
export const titleCase = str => {
@@ -73,19 +79,18 @@ export const titleCase = str => {
// if currentDate is on or before dueDate show current status
// else show past due status
export const verifyCurrentBalance = date => {
- const currentDate = moment();
+ const currentDate = new Date();
const dueDate = calcDueDate(date, 30);
- return currentDate.isSameOrBefore(dueDate);
+ return (
+ isBefore(currentDate, new Date(dueDate)) ||
+ isEqual(currentDate, new Date(dueDate))
+ );
};
-// receiving formatted date strings in the response
-// so we need to convert back to moment before sorting
export const sortStatementsByDate = statements => {
- const dateFormat = 'MM-DD-YYYY';
return statements.sort(
(a, b) =>
- moment(b.pSStatementDate, dateFormat) -
- moment(a.pSStatementDate, dateFormat),
+ new Date(b.pSStatementDateOutput) - new Date(a.pSStatementDateOutput),
);
};
diff --git a/src/applications/combined-debt-portal/debt-letters/components/Alerts.jsx b/src/applications/combined-debt-portal/debt-letters/components/Alerts.jsx
index c30d4fde2356..54195857fb60 100644
--- a/src/applications/combined-debt-portal/debt-letters/components/Alerts.jsx
+++ b/src/applications/combined-debt-portal/debt-letters/components/Alerts.jsx
@@ -1,7 +1,7 @@
import React from 'react';
-import moment from 'moment';
import { Link } from 'react-router-dom';
import { CONTACTS } from '@department-of-veterans-affairs/component-library/contacts';
+import { formatDate } from '../../combined/utils/helpers';
export const DownloadLettersAlert = () => (
Date: {moment().format('dddd, MMMM D, YYYY')}
+Date: {formatDate(new Date())}
Start/End time: 12:30 a.m. to 3:00 a.m. ET
Updated on - {moment(dateUpdated, 'MM-DD-YYYY').format('MMMM D, YYYY')} + {formatDate(dateUpdated)} .
diff --git a/src/applications/combined-debt-portal/medical-copays/components/DownloadStatement.jsx b/src/applications/combined-debt-portal/medical-copays/components/DownloadStatement.jsx index 119f58a0ffe0..db2c6b9ad9e2 100644 --- a/src/applications/combined-debt-portal/medical-copays/components/DownloadStatement.jsx +++ b/src/applications/combined-debt-portal/medical-copays/components/DownloadStatement.jsx @@ -1,9 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; -import moment from 'moment'; - import recordEvent from 'platform/monitoring/record-event'; import environment from 'platform/utilities/environment'; +import { parse } from 'date-fns'; +import { formatDate } from '../../combined/utils/helpers'; const handleDownloadClick = date => { return recordEvent({ @@ -13,9 +13,8 @@ const handleDownloadClick = date => { }; const DownloadStatement = ({ statementId, statementDate, fullName }) => { - const formattedStatementDate = moment(statementDate, 'MM-DD-YYYY').format( - 'MMMM D, YYYY', - ); + const parsedStatementDate = parse(statementDate, 'MMddyyyy', new Date()); + const formattedStatementDate = formatDate(parsedStatementDate); const downloadFileName = `${fullName} Veterans Medical copay statement dated ${formattedStatementDate}.pdf`; diff --git a/src/applications/combined-debt-portal/medical-copays/components/HTMLStatementLink.jsx b/src/applications/combined-debt-portal/medical-copays/components/HTMLStatementLink.jsx index a73de3546aa2..5ee4eaeffc70 100644 --- a/src/applications/combined-debt-portal/medical-copays/components/HTMLStatementLink.jsx +++ b/src/applications/combined-debt-portal/medical-copays/components/HTMLStatementLink.jsx @@ -1,14 +1,10 @@ import React from 'react'; import { Link } from 'react-router-dom'; -import moment from 'moment'; import PropTypes from 'prop-types'; import recordEvent from '~/platform/monitoring/record-event'; +import { formatDate } from '../../combined/utils/helpers'; const HTMLStatementLink = ({ id, statementDate }) => { - const formattedStatementDate = date => { - return moment(date, 'MM-DD-YYYY').format('MMMM D, YYYY'); - }; - return (
+ Respondent Burden: We need this information to
+ determine your eligibility for benefits (38 U.S.C. 3471). Title 38,
+ United States Code, allows us to ask for this information. We estimate
+ that you will need an average of {resBurden} minutes to review the
+ instructions, find the information, and complete this form. The VA
+ cannot conduct or sponsor a collection of information unless a valid OMB
+ (Office of Management and Budget) control number is displayed. You are
+ not required to respond to a collection of information if this number is
+ not displayed. Valid OMB control numbers can be located on the OMB
+ Internet Page at www.reginfo.gov/public/do/PRAMain. If desired, you can
+ call
+ Privacy Act information: VA will not disclose + information collected on this form to any source other than what has + been authorized under the Privacy Act of 1974 or Title 38, Code of + Federal Regulations 1.576 for routine uses (i.e., VA sends educational + forms or letters with a Veteran’s identifying information to the + Veteran’s school or training establishment to (1) assist the Veteran in + the completion of claims forms or (2) VA obtains further information as + may be necessary from the school for VA to properly process the + Veteran’s education claim or to monitor his or her progress during + training) as identified in the VA system of records. 58VA21/22/28, + Compensation, Pension, Education, and Veteran Readiness and Employment + Records - VA, published in the Federal Register. Your response is + required to obtain or retain benefits under this cost-free IBM + SkillsBuild Cybersecurity Training Program. While you do not have to + respond, VA cannot consider you approved to participate until we receive + this information per (38 U.S.C. 3452(b) and 3501(a)). Your responses are + confidential (38 U.S.C. 5701). Information submitted is subject to + verification through computer matching programs with other agencies. +
++ Licenses and certifications search page +
+Answer 2 questions to find out how your income may affect your VA health care eligibility and costs. diff --git a/src/applications/income-limits/containers/ResultsPage.jsx b/src/applications/income-limits/containers/ResultsPage.jsx index 3037a7f70d34..979e5f07aac9 100644 --- a/src/applications/income-limits/containers/ResultsPage.jsx +++ b/src/applications/income-limits/containers/ResultsPage.jsx @@ -13,7 +13,6 @@ import { getFifthAccordionHeader, } from '../utilities/results-accordions'; import { getPreviousYear, redirectIfFormIncomplete } from '../utilities/utils'; -import { customizeTitle } from '../utilities/customize-title'; /** * There are two pathways to displaying income ranges on this page @@ -24,11 +23,6 @@ import { customizeTitle } from '../utilities/customize-title'; const Results = ({ dependents, pastMode, results, router, year, zipCode }) => { const APPLY_URL = '/health-care/apply-for-health-care-form-10-10ez/'; const currentYear = new Date().getFullYear(); - const H1 = `Your income limits for ${year || currentYear}`; - - useEffect(() => { - document.title = customizeTitle(H1); - }); useEffect( () => { @@ -126,7 +120,7 @@ const Results = ({ dependents, pastMode, results, router, year, zipCode }) => { return ( <> -
Make any edits that you may need to. Then select{' '} Continue. diff --git a/src/applications/income-limits/containers/YearPage.jsx b/src/applications/income-limits/containers/YearPage.jsx index e7d30dc6ddd9..ba482be89f90 100644 --- a/src/applications/income-limits/containers/YearPage.jsx +++ b/src/applications/income-limits/containers/YearPage.jsx @@ -9,7 +9,6 @@ import { waitForRenderThenFocus } from '@department-of-veterans-affairs/platform import { ROUTES } from '../constants'; import { updateEditMode, updateYear } from '../actions'; -import { customizeTitle } from '../utilities/customize-title'; const YearPage = ({ editMode, @@ -21,11 +20,6 @@ const YearPage = ({ }) => { const [error, setError] = useState(false); const [submitted, setSubmitted] = useState(false); - const H1 = 'Income limits from past years going back to 2001'; - - useEffect(() => { - document.title = customizeTitle(H1); - }); useEffect( () => { @@ -93,7 +87,7 @@ const YearPage = ({ return ( <> -
Select the year you’d like to check income limits for. Then answer 2 questions to find out how your income may have affected your VA health diff --git a/src/applications/income-limits/containers/ZipCodePage.jsx b/src/applications/income-limits/containers/ZipCodePage.jsx index c46a2c55d8f2..6546bf33d7cf 100644 --- a/src/applications/income-limits/containers/ZipCodePage.jsx +++ b/src/applications/income-limits/containers/ZipCodePage.jsx @@ -14,7 +14,6 @@ import { updateZipValidationServiceError, } from '../actions'; import { validateZip } from '../api'; -import { customizeTitle } from '../utilities/customize-title'; const ZipCodePage = ({ editMode, @@ -36,10 +35,6 @@ const ZipCodePage = ({ : `What was your zip code last year?`; }; - useEffect(() => { - document.title = customizeTitle(determineH1()); - }); - // Checks that a zip was entered and is numbers only and has length of 5 const inputValid = zip => { return zipCode && zip.match(/^[0-9]+$/) && zip.length === 5; diff --git a/src/applications/income-limits/utilities/customize-title.js b/src/applications/income-limits/utilities/customize-title.js deleted file mode 100644 index a4b00c93fb2e..000000000000 --- a/src/applications/income-limits/utilities/customize-title.js +++ /dev/null @@ -1,9 +0,0 @@ -// Used to customize the
- You'll still be able to use you DS Logon{' '} + You'll still be able to use your DS Logon{' '} account on Defense Department websites after this date.