Skip to content

Commit

Permalink
fix: revert code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Aug 19, 2024
1 parent c6324ce commit 04a0a33
Showing 1 changed file with 28 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,28 @@ const getStyles = (theme: Theme) => ({
});

const deriveEnrollmentType =
(enrollments, currentProgramId): $Keys<typeof enrollmentTypes> => {
if (!currentProgramId) {
return enrollmentTypes.DONT_SHOW_TAG;
}
(enrollments, currentProgramId): $Keys<typeof enrollmentTypes> => {
if (!currentProgramId) {
return enrollmentTypes.DONT_SHOW_TAG;
}

const enrollmentsInCurrentProgram = enrollments
.filter(({ program }) => program === currentProgramId)
.map(({ status, lastUpdated }) => ({ status, lastUpdated }));
const enrollmentsInCurrentProgram = enrollments
.filter(({ program }) => program === currentProgramId)
.map(({ status, lastUpdated }) => ({ status, lastUpdated }));


const { ACTIVE, CANCELLED, COMPLETED } = enrollmentTypes;
if (enrollmentsInCurrentProgram.find(({ status }) => status === ACTIVE)) {
return ACTIVE;
} else if (enrollmentsInCurrentProgram.find(({ status }) => status === COMPLETED)) {
return COMPLETED;
} else if (enrollmentsInCurrentProgram.find(({ status }) => status === CANCELLED)) {
return CANCELLED;
}
return enrollmentTypes.DONT_SHOW_TAG;
};
const { ACTIVE, CANCELLED, COMPLETED } = enrollmentTypes;
if (enrollmentsInCurrentProgram.find(({ status }) => status === ACTIVE)) {
return ACTIVE;
} else if (enrollmentsInCurrentProgram.find(({ status }) => status === COMPLETED)) {
return COMPLETED;
} else if (enrollmentsInCurrentProgram.find(({ status }) => status === CANCELLED)) {
return CANCELLED;
}
return enrollmentTypes.DONT_SHOW_TAG;
};

const deriveEnrollmentOrgUnitIdAndDate = (enrollments, enrollmentType, currentProgramId): { orgUnitId?: string, enrolledAt?: string } => {
const deriveEnrollmentOrgUnitIdAndDate = (enrollments, enrollmentType, currentProgramId): {orgUnitId?: string, enrolledAt?: string} => {
if (!enrollments?.length) { return {}; }
if (!currentProgramId && enrollments.length) {
const { orgUnit: orgUnitId, enrolledAt } = enrollments[0];
Expand Down Expand Up @@ -201,19 +201,16 @@ const CardListItemIndex = ({
if (currentSearchScopeType === searchScopes.ALL_PROGRAMS) {
return null;
}
return (
<>
<ListEntry
name={i18n.t('Organisation unit')}
value={orgUnitName}
/>
<ListEntry
name={program?.enrollment?.enrollmentDateLabel ?? i18n.t('Date of enrollment')}
value={enrolledAt}
type={dataElementTypes.DATE}
/>
</>
);
return (<>
<ListEntry
name={i18n.t('Organisation unit')}
value={orgUnitName}
/> <ListEntry
name={program?.enrollment?.enrollmentDateLabel ?? i18n.t('Date of enrollment')}
value={enrolledAt}
type={dataElementTypes.DATE}
/>
</>);
};

return (
Expand Down

0 comments on commit 04a0a33

Please sign in to comment.