From 0dc2f01bbfcd6db9a2245ab902819fd9bcf45b4c Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Tue, 17 Dec 2024 09:49:21 +0100 Subject: [PATCH] chore: use action naming throughout the code --- ...llmentWithFirstStageDataEntry.container.js | 4 +- ...EnrollmentWithFirstStageDataEntry.types.js | 6 +- .../EnrollmentRegistrationEntry.types.js | 6 +- .../hooks/useBuildEnrollmentPayload.js | 4 +- .../withAskToCompleteEnrollment.js | 4 +- .../getConvertedRelatedStageEvent.js | 8 +-- .../getConvertedRelatedStageEvent.types.js | 4 +- .../EnrollmentAddEventPage.epics.js | 4 +- ...EnrollmentAddEventPageDefault.container.js | 4 +- ...lmentRegistrationEntryWrapper.component.js | 8 +-- .../DataEntryEnrollment.component.js | 10 ++-- .../DataEntryEnrollment.component.js | 10 ++-- .../Validated/validated.actions.js | 6 +- .../RelatedStagesActions.component.js | 60 +++++++++---------- .../RelatedStagesActions.types.js | 6 +- .../WidgetRelatedStages.types.js | 10 ++-- .../WidgetRelatedStages/constants.js | 8 +-- .../components/WidgetRelatedStages/index.js | 2 +- .../ValidationFunctions.js | 8 +-- .../relatedStageEventIsValid.types.js | 4 +- 20 files changed, 88 insertions(+), 88 deletions(-) diff --git a/src/core_modules/capture-core/components/DataEntries/Enrollment/EnrollmentWithFirstStageDataEntry/EnrollmentWithFirstStageDataEntry.container.js b/src/core_modules/capture-core/components/DataEntries/Enrollment/EnrollmentWithFirstStageDataEntry/EnrollmentWithFirstStageDataEntry.container.js index bcb91759f0..420c663669 100644 --- a/src/core_modules/capture-core/components/DataEntries/Enrollment/EnrollmentWithFirstStageDataEntry/EnrollmentWithFirstStageDataEntry.container.js +++ b/src/core_modules/capture-core/components/DataEntries/Enrollment/EnrollmentWithFirstStageDataEntry/EnrollmentWithFirstStageDataEntry.container.js @@ -10,7 +10,7 @@ const getSectionId = sectionId => (sectionId === Section.MAIN_SECTION_ID ? `${Section.MAIN_SECTION_ID}-stage` : sectionId); export const EnrollmentWithFirstStageDataEntry = (props: Props) => { - const { firstStageMetaData, relatedStageRef, relatedStageModesOptions, ...passOnProps } = props; + const { firstStageMetaData, relatedStageRef, relatedStageActionsOptions, ...passOnProps } = props; const { stage: { stageForm: firstStageFormFoundation, name: stageName }, } = firstStageMetaData; @@ -30,7 +30,7 @@ export const EnrollmentWithFirstStageDataEntry = (props: Props) => { ref={relatedStageRef} programId={passOnProps.programId} programStageId={firstStageMetaData.stage?.id} - actionTypesOptions={relatedStageModesOptions} + actionsOptions={relatedStageActionsOptions} /> ); diff --git a/src/core_modules/capture-core/components/DataEntries/Enrollment/EnrollmentWithFirstStageDataEntry/EnrollmentWithFirstStageDataEntry.types.js b/src/core_modules/capture-core/components/DataEntries/Enrollment/EnrollmentWithFirstStageDataEntry/EnrollmentWithFirstStageDataEntry.types.js index cbfbef6ea7..135a01646b 100644 --- a/src/core_modules/capture-core/components/DataEntries/Enrollment/EnrollmentWithFirstStageDataEntry/EnrollmentWithFirstStageDataEntry.types.js +++ b/src/core_modules/capture-core/components/DataEntries/Enrollment/EnrollmentWithFirstStageDataEntry/EnrollmentWithFirstStageDataEntry.types.js @@ -1,7 +1,7 @@ // @flow import type { ProgramStage, RenderFoundation } from '../../../../metaData'; import type { RelatedStageRefPayload } from '../../../WidgetRelatedStages'; -import { RelatedStageModes } from '../../../WidgetRelatedStages'; +import { relatedStageActions } from '../../../WidgetRelatedStages'; export type Props = { firstStageMetaData: { @@ -10,8 +10,8 @@ export type Props = { formFoundation: RenderFoundation, programId: string, relatedStageRef?: { current: ?RelatedStageRefPayload }, - relatedStageModesOptions?: { - [key: $Keys]: { + relatedStageActionsOptions?: { + [key: $Keys]: { hidden?: boolean, disabled?: boolean, disabledMessage?: string diff --git a/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/EnrollmentRegistrationEntry.types.js b/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/EnrollmentRegistrationEntry.types.js index edbe849b06..6eff575ea5 100644 --- a/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/EnrollmentRegistrationEntry.types.js +++ b/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/EnrollmentRegistrationEntry.types.js @@ -8,7 +8,7 @@ import type { ExistingUniqueValueDialogActionsComponent } from '../withErrorMess import type { InputAttribute } from './hooks/useFormValues'; import { RenderFoundation, ProgramStage } from '../../../metaData'; import type { RelatedStageRefPayload } from '../../WidgetRelatedStages'; -import { RelatedStageModes } from '../../WidgetRelatedStages'; +import { relatedStageActions } from '../../WidgetRelatedStages'; type TrackedEntityAttributes = Array<{ attribute: string, @@ -69,8 +69,8 @@ export type OwnProps = $ReadOnly<{| saveButtonText: (trackedEntityName: string) => string, firstStageMetaData?: ?{ stage: ?ProgramStage }, relatedStageRef?: { current: ?RelatedStageRefPayload }, - relatedStageModesOptions?: { - [key: $Keys]: { + relatedStageActionsOptions?: { + [key: $Keys]: { hidden?: boolean, disabled?: boolean, disabledMessage?: string diff --git a/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/hooks/useBuildEnrollmentPayload.js b/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/hooks/useBuildEnrollmentPayload.js index 20fc060c42..6a5566696a 100644 --- a/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/hooks/useBuildEnrollmentPayload.js +++ b/src/core_modules/capture-core/components/DataEntries/EnrollmentRegistrationEntry/hooks/useBuildEnrollmentPayload.js @@ -28,7 +28,7 @@ import { } from '../helpers'; import type { EnrollmentPayload } from '../EnrollmentRegistrationEntry.types'; import { geometryType, getPossibleTetFeatureTypeKey, buildGeometryProp } from '../../common/TEIAndEnrollment/geometry'; -import { RelatedStageModes } from '../../../WidgetRelatedStages'; +import { relatedStageActions } from '../../../WidgetRelatedStages'; import type { RelatedStageRefPayload } from '../../../WidgetRelatedStages'; type DataEntryReduxConverterProps = { @@ -184,7 +184,7 @@ export const useBuildEnrollmentPayload = ({ }, formHasError, programStageIdLinkedEventToRedirectTo: - relatedStageLinkedEvent && linkMode === RelatedStageModes.ENTER_DATA + relatedStageLinkedEvent && linkMode === relatedStageActions.ENTER_DATA ? relatedStageLinkedEvent.programStage : undefined, }; diff --git a/src/core_modules/capture-core/components/DataEntries/common/trackerEvent/withAskToCompleteEnrollment/withAskToCompleteEnrollment.js b/src/core_modules/capture-core/components/DataEntries/common/trackerEvent/withAskToCompleteEnrollment/withAskToCompleteEnrollment.js index f41e682ea4..c19649a0d7 100644 --- a/src/core_modules/capture-core/components/DataEntries/common/trackerEvent/withAskToCompleteEnrollment/withAskToCompleteEnrollment.js +++ b/src/core_modules/capture-core/components/DataEntries/common/trackerEvent/withAskToCompleteEnrollment/withAskToCompleteEnrollment.js @@ -6,7 +6,7 @@ import { CompleteModal } from './CompleteModal'; import { statusTypes as eventStatuses } from '../../../../../events/statusTypes'; import { type RenderFoundation } from '../../../../../metaData'; import { addEventSaveTypes } from '../../../../WidgetEnrollmentEventNew/DataEntry/addEventSaveTypes'; -import { RelatedStageModes } from '../../../../WidgetRelatedStages'; +import { relatedStageActions } from '../../../../WidgetRelatedStages'; import type { RelatedStageRefPayload } from '../../../../WidgetRelatedStages'; type Props = { @@ -63,7 +63,7 @@ const getAskToCompleteEnrollment = (InnerComponent: ComponentType) => (prop if ( askCompleteEnrollmentOnEventComplete && (isCompleted || saveType === addEventSaveTypes.COMPLETE) && - linkMode !== RelatedStageModes.ENTER_DATA + linkMode !== relatedStageActions.ENTER_DATA ) { setOpenCompleteModal(true); } else { diff --git a/src/core_modules/capture-core/components/DataEntries/converters/getConvertedRelatedStageEvent/getConvertedRelatedStageEvent.js b/src/core_modules/capture-core/components/DataEntries/converters/getConvertedRelatedStageEvent/getConvertedRelatedStageEvent.js index 5603b4d6ff..ad19d0ec9e 100644 --- a/src/core_modules/capture-core/components/DataEntries/converters/getConvertedRelatedStageEvent/getConvertedRelatedStageEvent.js +++ b/src/core_modules/capture-core/components/DataEntries/converters/getConvertedRelatedStageEvent/getConvertedRelatedStageEvent.js @@ -1,7 +1,7 @@ // @flow import log from 'loglevel'; import { generateUID } from '../../../../utils/uid/generateUID'; -import { RelatedStageModes } from '../../../WidgetRelatedStages'; +import { relatedStageActions } from '../../../WidgetRelatedStages'; import type { LinkedRequestEvent, ConvertedRelatedStageEventProps } from './getConvertedRelatedStageEvent.types'; import { errorCreator, pipe } from '../../../../../capture-core-utils'; import { convertClientToServer, convertFormToClient } from '../../../../converters'; @@ -35,7 +35,7 @@ const getEventDetailsByLinkMode = ({ status: 'SCHEDULE', }; - if (linkMode === RelatedStageModes.SCHEDULE_IN_ORG) { + if (linkMode === relatedStageActions.SCHEDULE_IN_ORG) { const { scheduledAt: linkedEventScheduledAt, orgUnit: linkedEventOrgUnit } = relatedStageDataValues; if (!linkedEventScheduledAt || !linkedEventOrgUnit) { // Business logic dictates that these values will not be null here @@ -56,7 +56,7 @@ const getEventDetailsByLinkMode = ({ }); } - if (linkMode === RelatedStageModes.ENTER_DATA) { + if (linkMode === relatedStageActions.ENTER_DATA) { const { orgUnit: linkedEventOrgUnit } = relatedStageDataValues; if (!linkedEventOrgUnit) { throw new Error( @@ -75,7 +75,7 @@ const getEventDetailsByLinkMode = ({ }); } - if (linkMode === RelatedStageModes.LINK_EXISTING_RESPONSE) { + if (linkMode === relatedStageActions.LINK_EXISTING_RESPONSE) { const { linkedEventId } = relatedStageDataValues; return { linkedEvent: null, diff --git a/src/core_modules/capture-core/components/DataEntries/converters/getConvertedRelatedStageEvent/getConvertedRelatedStageEvent.types.js b/src/core_modules/capture-core/components/DataEntries/converters/getConvertedRelatedStageEvent/getConvertedRelatedStageEvent.types.js index 7a40b70c2e..360a0ab676 100644 --- a/src/core_modules/capture-core/components/DataEntries/converters/getConvertedRelatedStageEvent/getConvertedRelatedStageEvent.types.js +++ b/src/core_modules/capture-core/components/DataEntries/converters/getConvertedRelatedStageEvent/getConvertedRelatedStageEvent.types.js @@ -1,6 +1,6 @@ // @flow import type { RelatedStageDataValueStates, RelatedStageRelationshipType } from '../../../WidgetRelatedStages'; -import { RelatedStageModes } from '../../../WidgetRelatedStages'; +import { relatedStageActions } from '../../../WidgetRelatedStages'; type CommonEventDetails = { event: string, @@ -28,7 +28,7 @@ export type LinkedRequestEvent = { } export type ConvertedRelatedStageEventProps = {| - linkMode: $Keys, + linkMode: $Keys, relatedStageDataValues: RelatedStageDataValueStates, programId: string, teiId?: ?string, diff --git a/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPage.epics.js b/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPage.epics.js index 6b18a26e4c..7fd2050e30 100644 --- a/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPage.epics.js +++ b/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPage.epics.js @@ -11,7 +11,7 @@ import { rollbackEnrollmentEvents, saveFailed, } from '../common/EnrollmentOverviewDomain/enrollment.actions'; -import { RelatedStageModes } from '../../WidgetRelatedStages'; +import { relatedStageActions } from '../../WidgetRelatedStages'; import { buildUrlQueryString } from '../../../utils/routing'; const shouldNavigateWithRelatedStage = ({ @@ -21,7 +21,7 @@ const shouldNavigateWithRelatedStage = ({ history, }) => { if (linkMode && linkedEventId) { - if (linkMode === RelatedStageModes.ENTER_DATA) { + if (linkMode === relatedStageActions.ENTER_DATA) { const navigate = () => history.push(`/enrollmentEventEdit?${buildUrlQueryString({ eventId: linkedEventId, orgUnitId: linkedOrgUnitId, diff --git a/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.container.js b/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.container.js index c7c32a4f76..a3500cd1f3 100644 --- a/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.container.js +++ b/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.container.js @@ -11,7 +11,7 @@ import { buildUrlQueryString, useLocationQuery } from '../../../../utils/routing import { useProgramInfo } from '../../../../hooks/useProgramInfo'; import { EnrollmentAddEventTopBar, useEnrollmentAddEventTopBar } from '../TopBar'; import { deleteEnrollment, fetchEnrollments } from '../../Enrollment/EnrollmentPage.actions'; -import { RelatedStageModes } from '../../../WidgetRelatedStages'; +import { relatedStageActions } from '../../../WidgetRelatedStages'; import { useWidgetDataFromStore } from '../hooks'; import { useHideWidgetByRuleLocations } from '../../Enrollment/EnrollmentPageDefault/hooks'; @@ -70,7 +70,7 @@ export const EnrollmentAddEventPageDefault = ({ const handleSave = useCallback( ({ enrollments, events, linkMode }) => { - if (linkMode && linkMode === RelatedStageModes.ENTER_DATA) return; + if (linkMode && linkMode === relatedStageActions.ENTER_DATA) return; const nowClient = fromClientDate(new Date()); const nowServer = new Date(nowClient.getServerZonedISOString()); diff --git a/src/core_modules/capture-core/components/Pages/New/EnrollmentRegistrationEntryWrapper.component.js b/src/core_modules/capture-core/components/Pages/New/EnrollmentRegistrationEntryWrapper.component.js index ac0b51288b..8c65e761b5 100644 --- a/src/core_modules/capture-core/components/Pages/New/EnrollmentRegistrationEntryWrapper.component.js +++ b/src/core_modules/capture-core/components/Pages/New/EnrollmentRegistrationEntryWrapper.component.js @@ -4,7 +4,7 @@ import { useDispatch } from 'react-redux'; import { cleanUpUid } from './NewPage.actions'; import { EnrollmentRegistrationEntry } from '../../DataEntries/EnrollmentRegistrationEntry/EnrollmentRegistrationEntry.container'; import type { OwnProps } from '../../DataEntries/EnrollmentRegistrationEntry/EnrollmentRegistrationEntry.types'; -import { RelatedStageModes } from '../../WidgetRelatedStages'; +import { relatedStageActions } from '../../WidgetRelatedStages'; export const EnrollmentRegistrationEntryWrapper: ComponentType = (props) => { const dispatch = useDispatch(); @@ -12,9 +12,9 @@ export const EnrollmentRegistrationEntryWrapper: ComponentType = (prop dispatch(cleanUpUid()); }, [dispatch]); - const relatedStageModesOptions = { - [RelatedStageModes.LINK_EXISTING_RESPONSE]: { hidden: true }, + const relatedStageActionsOptions = { + [relatedStageActions.LINK_EXISTING_RESPONSE]: { hidden: true }, }; - return ; + return ; }; diff --git a/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/DataEntry/Enrollment/DataEntryEnrollment.component.js b/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/DataEntry/Enrollment/DataEntryEnrollment.component.js index fb4dbb4837..710ff035c1 100644 --- a/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/DataEntry/Enrollment/DataEntryEnrollment.component.js +++ b/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/DataEntry/Enrollment/DataEntryEnrollment.component.js @@ -6,7 +6,7 @@ import { DATA_ENTRY_ID } from '../../registerTei.const'; import enrollmentClasses from './enrollment.module.css'; import { EnrollmentRegistrationEntry } from '../../../../../DataEntries'; import type { Props } from './dataEntryEnrollment.types'; -import { RelatedStageModes } from '../../../../../WidgetRelatedStages'; +import { relatedStageActions } from '../../../../../WidgetRelatedStages'; const NewEnrollmentRelationshipPlain = ({ @@ -21,12 +21,12 @@ const NewEnrollmentRelationshipPlain = ExistingUniqueValueDialogActions, }: Props) => { const fieldOptions = { theme, fieldLabelMediaBasedClass: enrollmentClasses.fieldLabelMediaBased }; - const relatedStageModesOptions = { - [RelatedStageModes.ENTER_DATA]: { + const relatedStageActionsOptions = { + [relatedStageActions.ENTER_DATA]: { disabled: true, disabledMessage: i18n.t('Enter details now is not available when creating a relationship'), }, - [RelatedStageModes.LINK_EXISTING_RESPONSE]: { hidden: true }, + [relatedStageActions.LINK_EXISTING_RESPONSE]: { hidden: true }, }; return ( @@ -45,7 +45,7 @@ const NewEnrollmentRelationshipPlain = renderDuplicatesDialogActions={renderDuplicatesDialogActions} renderDuplicatesCardActions={renderDuplicatesCardActions} ExistingUniqueValueDialogActions={ExistingUniqueValueDialogActions} - relatedStageModesOptions={relatedStageModesOptions} + relatedStageActionsOptions={relatedStageActionsOptions} /> ); }; diff --git a/src/core_modules/capture-core/components/Pages/common/TEIRelationshipsWidget/RegisterTei/DataEntry/Enrollment/DataEntryEnrollment.component.js b/src/core_modules/capture-core/components/Pages/common/TEIRelationshipsWidget/RegisterTei/DataEntry/Enrollment/DataEntryEnrollment.component.js index 406eacdc5f..7d20b9f6ca 100644 --- a/src/core_modules/capture-core/components/Pages/common/TEIRelationshipsWidget/RegisterTei/DataEntry/Enrollment/DataEntryEnrollment.component.js +++ b/src/core_modules/capture-core/components/Pages/common/TEIRelationshipsWidget/RegisterTei/DataEntry/Enrollment/DataEntryEnrollment.component.js @@ -6,7 +6,7 @@ import { DATA_ENTRY_ID } from '../../registerTei.const'; import enrollmentClasses from './enrollment.module.css'; import { EnrollmentRegistrationEntry } from '../../../../../../DataEntries'; import type { Props } from './dataEntryEnrollment.types'; -import { RelatedStageModes } from '../../../../../../WidgetRelatedStages'; +import { relatedStageActions } from '../../../../../../WidgetRelatedStages'; const NewEnrollmentRelationshipPlain = ({ @@ -22,12 +22,12 @@ const NewEnrollmentRelationshipPlain = ExistingUniqueValueDialogActions, }: Props) => { const fieldOptions = { theme, fieldLabelMediaBasedClass: enrollmentClasses.fieldLabelMediaBased }; - const relatedStageModesOptions = { - [RelatedStageModes.ENTER_DATA]: { + const relatedStageActionsOptions = { + [relatedStageActions.ENTER_DATA]: { disabled: true, disabledMessage: i18n.t('Enter details now is not available when creating a relationship'), }, - [RelatedStageModes.LINK_EXISTING_RESPONSE]: { hidden: true }, + [relatedStageActions.LINK_EXISTING_RESPONSE]: { hidden: true }, }; return ( @@ -47,7 +47,7 @@ const NewEnrollmentRelationshipPlain = renderDuplicatesCardActions={renderDuplicatesCardActions} ExistingUniqueValueDialogActions={ExistingUniqueValueDialogActions} trackedEntityInstanceAttributes={inheritedAttributes} - relatedStageModesOptions={relatedStageModesOptions} + relatedStageActionsOptions={relatedStageActionsOptions} /> ); }; diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/validated.actions.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/validated.actions.js index ddd8c75878..f14942ced5 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/validated.actions.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/validated.actions.js @@ -1,7 +1,7 @@ // @flow import { actionCreator } from '../../../actions/actions.utils'; import { effectMethods } from '../../../trackerOffline'; -import { RelatedStageModes } from '../../WidgetRelatedStages'; +import { relatedStageActions } from '../../WidgetRelatedStages'; import type { RequestEvent, LinkedRequestEvent } from '../../DataEntries'; import type { ExternalSaveHandler } from '../common.types'; @@ -37,7 +37,7 @@ export const requestSaveEvent = ({ linkedEvent: ?LinkedRequestEvent, relationship: ?Object, serverData: Object, - linkMode: ?$Keys, + linkMode: ?$Keys, onSaveExternal: ?ExternalSaveHandler, onSaveSuccessActionType?: string, onSaveErrorActionType?: string, @@ -62,7 +62,7 @@ export const setSaveEnrollmentEventInProgress = ({ requestEventId: string, linkedEventId: ?string, linkedOrgUnitId: ?string, - linkMode: ?$Keys, + linkMode: ?$Keys, }) => actionCreator(newEventWidgetActionTypes.SET_SAVE_ENROLLMENT_EVENT_IN_PROGRESS)({ requestEventId, linkedEventId, 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 519cb05cea..acf6c6e0a5 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 @@ -4,7 +4,7 @@ import i18n from '@dhis2/d2-i18n'; import { Button, colors, Radio, spacers, spacersNum } from '@dhis2/ui'; import { withStyles } from '@material-ui/core'; import { ConditionalTooltip } from 'capture-core/components/Tooltips/ConditionalTooltip'; -import { actions as RelatedStagesActionTypes, mainOptionTranslatedTexts, relatedStageStatus } from '../constants'; +import { relatedStageActions, mainOptionTranslatedTexts, relatedStageStatus } from '../constants'; import { useCanAddNewEventToStage } from '../hooks/useCanAddNewEventToStage'; import { DataSection } from '../../DataSection'; import { ScheduleInOrgUnit } from '../ScheduleInOrgUnit'; @@ -41,7 +41,7 @@ const styles = () => ({ }); const Schedule = ({ - actionTypesOptions, + actionsOptions, linkableEvents, selectedAction, updateSelectedAction, @@ -49,7 +49,7 @@ const Schedule = ({ canAddNewEventToStage, }) => { const { hidden, disabled, disabledMessage } = - (actionTypesOptions && actionTypesOptions[RelatedStagesActionTypes.SCHEDULE_IN_ORG]) || {}; + (actionsOptions && actionsOptions[relatedStageActions.SCHEDULE_IN_ORG]) || {}; if (hidden) { return null; } @@ -67,25 +67,25 @@ const Schedule = ({ return ( updateSelectedAction(e.value)} - value={RelatedStagesActionTypes.SCHEDULE_IN_ORG} + value={relatedStageActions.SCHEDULE_IN_ORG} /> ); }; const EnterData = ({ - actionTypesOptions, + actionsOptions, linkableEvents, selectedAction, updateSelectedAction, @@ -93,7 +93,7 @@ const EnterData = ({ canAddNewEventToStage, }) => { const { hidden, disabled, disabledMessage } = - (actionTypesOptions && actionTypesOptions[RelatedStagesActionTypes.ENTER_DATA]) || {}; + (actionsOptions && actionsOptions[relatedStageActions.ENTER_DATA]) || {}; if (hidden) { return null; } @@ -111,32 +111,32 @@ const EnterData = ({ return ( updateSelectedAction(e.value)} - value={RelatedStagesActionTypes.ENTER_DATA} + value={relatedStageActions.ENTER_DATA} /> ); }; const LinkExistingResponse = ({ - actionTypesOptions, + actionsOptions, linkableEvents, selectedAction, updateSelectedAction, programStage, }) => { const { hidden, disabled, disabledMessage } = - (actionTypesOptions && actionTypesOptions[RelatedStagesActionTypes.LINK_EXISTING_RESPONSE]) || {}; + (actionsOptions && actionsOptions[relatedStageActions.LINK_EXISTING_RESPONSE]) || {}; if (hidden) { return null; } @@ -154,18 +154,18 @@ const LinkExistingResponse = ({ return ( updateSelectedAction(e.value)} - value={RelatedStagesActionTypes.LINK_EXISTING_RESPONSE} + value={relatedStageActions.LINK_EXISTING_RESPONSE} /> ); @@ -183,13 +183,13 @@ const RelatedStagesActionsPlain = ({ constraint, errorMessages, saveAttempted, - actionTypesOptions, + actionsOptions, }: Props) => { const { programStage } = useProgramStageInfo(constraint?.programStage?.id); const selectedAction = useMemo(() => relatedStagesDataValues.linkMode, [relatedStagesDataValues.linkMode]); - const updateSelectedAction = (action: ?$Values) => { + const updateSelectedAction = (action: ?$Values) => { setRelatedStagesDataValues(prevState => ({ ...prevState, linkMode: action, @@ -210,7 +210,7 @@ const RelatedStagesActionsPlain = ({ {type === relatedStageStatus.LINKABLE && ( <> )} - {selectedAction === RelatedStagesActionTypes.SCHEDULE_IN_ORG && ( + {selectedAction === relatedStageActions.SCHEDULE_IN_ORG && ( )} - {selectedAction === RelatedStagesActionTypes.ENTER_DATA && ( + {selectedAction === relatedStageActions.ENTER_DATA && ( )} - {selectedAction === RelatedStagesActionTypes.LINK_EXISTING_RESPONSE && ( + {selectedAction === relatedStageActions.LINK_EXISTING_RESPONSE && ( void, setRelatedStagesDataValues: (() => Object) => void, - actionTypesOptions?: { - [key: $Keys]: { + actionsOptions?: { + [key: $Keys]: { hidden?: boolean, disabled?: boolean, disabledMessage?: string diff --git a/src/core_modules/capture-core/components/WidgetRelatedStages/WidgetRelatedStages.types.js b/src/core_modules/capture-core/components/WidgetRelatedStages/WidgetRelatedStages.types.js index c433e40c89..7876e528c1 100644 --- a/src/core_modules/capture-core/components/WidgetRelatedStages/WidgetRelatedStages.types.js +++ b/src/core_modules/capture-core/components/WidgetRelatedStages/WidgetRelatedStages.types.js @@ -1,5 +1,5 @@ // @flow -import { RelatedStageModes } from './index'; +import { relatedStageActions } from './index'; import type { Constraint } from './RelatedStagesActions/RelatedStagesActions.types'; export type RelationshipType = {| @@ -19,8 +19,8 @@ export type Props = {| programId: string, enrollmentId?: string, programStageId: string, - actionTypesOptions?: { - [key: $Keys]: { + actionsOptions?: { + [key: $Keys]: { hidden?: boolean, disabled?: boolean, disabledMessage?: string @@ -28,7 +28,7 @@ export type Props = {| }, |} export type RelatedStageDataValueStates = {| - linkMode: ?$Keys, + linkMode: ?$Keys, scheduledAt: string, scheduledAtFormatError: ?{error: ?string, errorCode: ?string}, orgUnit: ?{ @@ -57,7 +57,7 @@ export type RelatedStageRefPayload = { getLinkedStageValues: () => { selectedRelationshipType: RelatedStageRelationshipType, relatedStageDataValues: RelatedStageDataValueStates, - linkMode: ?$Keys, + linkMode: ?$Keys, }, eventHasLinkableStageRelationship: () => boolean, formIsValidOnSave: () => boolean, diff --git a/src/core_modules/capture-core/components/WidgetRelatedStages/constants.js b/src/core_modules/capture-core/components/WidgetRelatedStages/constants.js index d8e57bb9a4..7b021f5fc5 100644 --- a/src/core_modules/capture-core/components/WidgetRelatedStages/constants.js +++ b/src/core_modules/capture-core/components/WidgetRelatedStages/constants.js @@ -6,14 +6,14 @@ export const relatedStageStatus = Object.freeze({ AMBIGUOUS_RELATIONSHIPS: 'AMBIGUOUS_RELATIONSHIPS', }); -export const actions = Object.freeze({ +export const relatedStageActions = Object.freeze({ SCHEDULE_IN_ORG: 'SCHEDULE_IN_ORG', LINK_EXISTING_RESPONSE: 'LINK_EXISTING_RESPONSE', ENTER_DATA: 'ENTER_DATA', }); export const mainOptionTranslatedTexts = { - [actions.SCHEDULE_IN_ORG]: i18n.t('Schedule'), - [actions.ENTER_DATA]: i18n.t('Enter details now'), - [actions.LINK_EXISTING_RESPONSE]: i18n.t('Link to an existing event'), + [relatedStageActions.SCHEDULE_IN_ORG]: i18n.t('Schedule'), + [relatedStageActions.ENTER_DATA]: i18n.t('Enter details now'), + [relatedStageActions.LINK_EXISTING_RESPONSE]: i18n.t('Link to an existing event'), }; diff --git a/src/core_modules/capture-core/components/WidgetRelatedStages/index.js b/src/core_modules/capture-core/components/WidgetRelatedStages/index.js index 082bdd7c93..e75b93c8cc 100644 --- a/src/core_modules/capture-core/components/WidgetRelatedStages/index.js +++ b/src/core_modules/capture-core/components/WidgetRelatedStages/index.js @@ -5,5 +5,5 @@ export type { RelatedStageRefPayload, RelatedStageRelationshipType, } from './WidgetRelatedStages.types'; -export { actions as RelatedStageModes } from './constants'; +export { relatedStageActions } from './constants'; export { relatedStageWidgetIsValid } from './relatedStageEventIsValid/relatedStageEventIsValid'; diff --git a/src/core_modules/capture-core/components/WidgetRelatedStages/relatedStageEventIsValid/ValidationFunctions.js b/src/core_modules/capture-core/components/WidgetRelatedStages/relatedStageEventIsValid/ValidationFunctions.js index 219e354ded..0092d76bab 100644 --- a/src/core_modules/capture-core/components/WidgetRelatedStages/relatedStageEventIsValid/ValidationFunctions.js +++ b/src/core_modules/capture-core/components/WidgetRelatedStages/relatedStageEventIsValid/ValidationFunctions.js @@ -2,7 +2,7 @@ import i18n from '@dhis2/d2-i18n'; import { isValidOrgUnit } from '../../../../capture-core-utils/validators/form'; import { isValidDate } from '../../../utils/validation/validators/form'; -import { actions as RelatedStageModes } from '../constants'; +import { relatedStageActions } from '../index'; type Props = { scheduledAt: ?string, @@ -87,8 +87,8 @@ const linkToExistingResponse = (props) => { export const ValidationFunctionsByLinkMode: { [key: string]: (props: ?Props) => boolean } = { - [RelatedStageModes.SCHEDULE_IN_ORG]: props => scheduleInOrgUnit(props), - [RelatedStageModes.ENTER_DATA]: props => enterData(props), - [RelatedStageModes.LINK_EXISTING_RESPONSE]: props => linkToExistingResponse(props), + [relatedStageActions.SCHEDULE_IN_ORG]: props => scheduleInOrgUnit(props), + [relatedStageActions.ENTER_DATA]: props => enterData(props), + [relatedStageActions.LINK_EXISTING_RESPONSE]: props => linkToExistingResponse(props), }; diff --git a/src/core_modules/capture-core/components/WidgetRelatedStages/relatedStageEventIsValid/relatedStageEventIsValid.types.js b/src/core_modules/capture-core/components/WidgetRelatedStages/relatedStageEventIsValid/relatedStageEventIsValid.types.js index a8211930b7..1f4fa5cb35 100644 --- a/src/core_modules/capture-core/components/WidgetRelatedStages/relatedStageEventIsValid/relatedStageEventIsValid.types.js +++ b/src/core_modules/capture-core/components/WidgetRelatedStages/relatedStageEventIsValid/relatedStageEventIsValid.types.js @@ -1,9 +1,9 @@ // @flow import type { ErrorMessagesForRelatedStages } from '../RelatedStagesActions'; -import { RelatedStageModes } from '../index'; +import { relatedStageActions } from '../index'; export type RelatedStageIsValidProps = {| - linkMode: ?$Keys, + linkMode: ?$Keys, scheduledAt: ?string, scheduledAtFormatError: ?{error: ?string, errorCode: ?string}, orgUnit: ?{