From 608b43dbe6a5119a7eefa7c5e1e3c0069d28b66e Mon Sep 17 00:00:00 2001 From: henrikmv Date: Mon, 12 Aug 2024 17:37:55 +0200 Subject: [PATCH] fix: missing flow and types --- .../RelatedStagesActions.component.js | 1 - .../hooks/useCanAddNewEventToStage.js | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core_modules/capture-core/components/WidgetRelatedStages/RelatedStagesActions/RelatedStagesActions.component.js b/src/core_modules/capture-core/components/WidgetRelatedStages/RelatedStagesActions/RelatedStagesActions.component.js index 82e6cf4202..5a87eaec91 100644 --- a/src/core_modules/capture-core/components/WidgetRelatedStages/RelatedStagesActions/RelatedStagesActions.component.js +++ b/src/core_modules/capture-core/components/WidgetRelatedStages/RelatedStagesActions/RelatedStagesActions.component.js @@ -71,7 +71,6 @@ export const RelatedStagesActionsPlain = ({ linkMode: action, })); }; - const canAddNewEventToStage = useCanAddNewEventToStage(programStage, linkableEvents); if (!programStage) { diff --git a/src/core_modules/capture-core/components/WidgetRelatedStages/hooks/useCanAddNewEventToStage.js b/src/core_modules/capture-core/components/WidgetRelatedStages/hooks/useCanAddNewEventToStage.js index e0c8eba624..1d7c5a7a21 100644 --- a/src/core_modules/capture-core/components/WidgetRelatedStages/hooks/useCanAddNewEventToStage.js +++ b/src/core_modules/capture-core/components/WidgetRelatedStages/hooks/useCanAddNewEventToStage.js @@ -1,13 +1,18 @@ +// @flow import { useMemo } from 'react'; import { useSelector } from 'react-redux'; +import { ProgramStage } from '../../../metaData'; +import type { LinkableEvent } from '../RelatedStagesActions/RelatedStagesActions.types'; -export const useCanAddNewEventToStage = (programStage, existingRelatedEvents) => { +export const useCanAddNewEventToStage = (programStage: ?ProgramStage, existingRelatedEvents: LinkableEvent[]) => { + console.log('programStage', programStage); + console.log('existingRelatedEvents', existingRelatedEvents); const hiddenProgramStages = useSelector(({ rulesEffectsHiddenProgramStageDesc }) => rulesEffectsHiddenProgramStageDesc?.['enrollmentEvent-newEvent'], ); return useMemo(() => { - const isProgramStageHidden = hiddenProgramStages?.[programStage.id]; + const isProgramStageHidden = hiddenProgramStages?.[programStage?.id]; if (isProgramStageHidden) { return false; }