Skip to content

Commit

Permalink
Date fixing things
Browse files Browse the repository at this point in the history
  • Loading branch information
wullaski committed Nov 27, 2024
1 parent bf3a9b9 commit a40b507
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ const PendingReferralCard = ({ referral, handleClick, index }) => {
? '1 appointment'
: `${referral.numberOfAppointments} appointments`;

const expiration = format(
parseISO(referral.ReferralExpirationDate),
'MMMM d, yyyy',
);
const parsedDate = parseISO(referral.ReferralExpirationDate);
const expiration = format(parsedDate, 'MMMM d, yyyy');

return (
<ListItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ReferralList from './ReferralList';
import { createReferrals } from '../utils/referrals';

describe('VAOS Component: ReferralList', () => {
const referrals = createReferrals(2, new Date().toISOString());
const referrals = createReferrals(2, '2024-11-27');
const emptyReferrals = [];

it('should render the referral list with referrals', () => {
Expand Down
13 changes: 10 additions & 3 deletions src/applications/vaos/referral-appointments/utils/referrals.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,23 @@ const createReferral = (startDate, uuid) => {
* Creates a referral array of any length.
*
* @param {Number} numberOfReferrals The number of referrals to create in the array
* @param {String} baseDate The date to base the referrals around
* @param {String} baseDate The date in 'yyyy-MM-dd' format to base the referrals around
* @returns {Array} Referrals array
*/
const createReferrals = (numberOfReferrals = 3, baseDate) => {
const [year, month, day] = baseDate.split('-');
const baseDateObject = new Date(year, month - 1, day);
const referrals = [];
const baseUUID = 'add2f0f4-a1ea-4dea-a504-a54ab57c68';
for (let i = 0; i < numberOfReferrals; i++) {
const startDate = addDays(new Date(baseDate), i);
const startDate = addDays(baseDateObject, i);
const mydFormat = 'yyyy-MM-dd';
const referralDate = format(startDate, mydFormat);
referrals.push(
createReferral(startDate, `${baseUUID}${i.toString().padStart(2, '0')}`),
createReferral(
referralDate,
`${baseUUID}${i.toString().padStart(2, '0')}`,
),
);
}
return referrals;
Expand Down

0 comments on commit a40b507

Please sign in to comment.