Skip to content

Commit

Permalink
fix: Update date formatting in the new Study Card Component (#1131)
Browse files Browse the repository at this point in the history
  • Loading branch information
PintoGideon authored Mar 27, 2024
1 parent 54cad39 commit ffeda38
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/Pacs/components/StudyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Skeleton,
Tooltip,
} from "@patternfly/react-core";
import { format, parse } from "date-fns";
import { Alert } from "antd";
import { useContext, useEffect, useState } from "react";
import { DotsIndicator } from "../../Common";
Expand All @@ -32,6 +33,14 @@ const StudyCardCopy = ({ study }: { study: any }) => {
const userPreferencesArray = userPreferences && Object.keys(userPreferences);
const studyInstanceUID = study.StudyInstanceUID.value;

const studyDate = study.StudyDate.value;
const parsedDate = parse(studyDate, "yyyyMMdd", new Date());
const formattedDate = Number.isNaN(
parsedDate.getTime(),
) /* Check if parsedDate is a valid date */
? studyDate
: format(parsedDate, "MMMM d, yyyy");

useEffect(() => {
if (studyPullTracker && pullStudy) {
const studyBeingTracked = studyPullTracker[studyInstanceUID];
Expand Down Expand Up @@ -122,7 +131,7 @@ const StudyCardCopy = ({ study }: { study: any }) => {
<div>
{study.NumberOfStudyRelatedSeries.value &&
study.NumberOfStudyRelatedSeries.value}{" "}
series, {`${formatStudyDate(study.StudyDate.value)}`}
series, {formattedDate}
</div>
</div>
<div className="flex-studies-item ">
Expand Down

0 comments on commit ffeda38

Please sign in to comment.