Skip to content

Commit

Permalink
date format changed
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityyaX committed Dec 15, 2023
1 parent 1f5ea20 commit 3c40842
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ export const PatientHome = (props: any) => {
setAssignedVolunteerObject(patientData.assigned_to_object);
}, [patientData.assigned_to_object]);

function formatDateOfBirth(dateString) {
if (!dateString) return null;

const date = new Date(dateString);
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();

const formattedDay = day < 10 ? `0${day}` : day;
const formattedMonth = month < 10 ? `0${month}` : month;

return `${formattedDay}/${formattedMonth}/${year}`;
}

const handleTransferComplete = (shift: any) => {
setModalFor({ ...modalFor, loading: true });
dispatch(completeTransfer({ externalId: modalFor })).then(() => {
Expand Down Expand Up @@ -572,7 +586,7 @@ export const PatientHome = (props: any) => {
Date of Birth
</div>
<div className="mt-1 text-sm font-medium leading-5">
{patientData?.date_of_birth}
{formatDateOfBirth(patientData?.date_of_birth)}
</div>
</div>
<div className="sm:col-span-1">
Expand Down

0 comments on commit 3c40842

Please sign in to comment.