Skip to content

Commit

Permalink
feat: quick actions & stage selector
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Aug 10, 2024
1 parent 1b4d3d3 commit 92560b7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const EnrollmentQuickActionsComponent = ({ stages, events, ruleEffects, classes
() =>
stagesWithEventCount.every(
programStage =>
(!programStage.dataAccess.write) ||
(!programStage.repeatable && programStage.eventCount > 0) ||
hiddenProgramStageRuleEffects?.find(ruleEffect => ruleEffect.id === programStage.id),
),
Expand All @@ -61,35 +62,37 @@ const EnrollmentQuickActionsComponent = ({ stages, events, ruleEffects, classes
onClose={() => setOpen(false)}
onOpen={() => setOpen(true)}
>
{ready && <div
className={classes.contentContainer}
data-test={'quick-action-button-container'}
>
<QuickActionButton
icon={<IconAdd24 color={colors.grey700} />}
label={i18n.t('New Event')}
onClickAction={() => onNavigationFromQuickActions(tabMode.REPORT)}
dataTest={'quick-action-button-report'}
disable={noStageAvailable}
/>
{ready && (
<div
className={classes.contentContainer}
data-test={'quick-action-button-container'}
>
<QuickActionButton
icon={<IconAdd24 color={colors.grey700} />}
label={i18n.t('New Event')}
onClickAction={() => onNavigationFromQuickActions(tabMode.REPORT)}
dataTest={'quick-action-button-report'}
disable={noStageAvailable}
/>

<QuickActionButton
icon={<IconCalendar24 color={colors.grey700} />}
label={i18n.t('Schedule an event')}
onClickAction={() => onNavigationFromQuickActions(tabMode.SCHEDULE)}
dataTest={'quick-action-button-schedule'}
disable={noStageAvailable}
/>
<QuickActionButton
icon={<IconCalendar24 color={colors.grey700} />}
label={i18n.t('Schedule an event')}
onClickAction={() => onNavigationFromQuickActions(tabMode.SCHEDULE)}
dataTest={'quick-action-button-schedule'}
disable={noStageAvailable}
/>

{/* DHIS2-13016: Should hide Make referral until the feature is developped
{/* DHIS2-13016: Should hide Make referral until the feature is developped
<QuickActionButton
icon={<IconArrowRightMulti24 />}
label={i18n.t('Make referral')}
onClickAction={() => onNavigationFromQuickActions(tabMode.REFER)}
dataTest={'quick-action-button-refer'}
disable={noStageAvailable}
/> */}
</div>}
</div>
)}
</Widget>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ProgramStageSelectorComponentPlain = ({ programStages, onSelectProgramStag
<div className={classes.container}>
{programStages.map((programStage) => {
const disableStage =
(!programStage.repeatable && programStage.eventCount > 0) || programStage.hiddenProgramStage;
!programStage.dataAccess.write || (!programStage.repeatable && programStage.eventCount > 0) || programStage.hiddenProgramStage;
return (
<div
key={programStage.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const ProgramStageSelector = ({ programId, orgUnitId, teiId, enrollmentId
const programStages = useMemo(() => !programLoading && program?.programStages?.reduce((accStage, currentStage) => {
accStage.push({
id: currentStage.id,
dataAccess: currentStage.access.data,
eventCount: (enrollment?.events
?.filter(event => event.programStage === currentStage.id)
?.length
Expand Down

0 comments on commit 92560b7

Please sign in to comment.