Skip to content

Commit

Permalink
chore: use action naming throughout the code
Browse files Browse the repository at this point in the history
  • Loading branch information
simonadomnisoru committed Dec 17, 2024
1 parent d137e8e commit 0dc2f01
Show file tree
Hide file tree
Showing 20 changed files with 88 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,7 +30,7 @@ export const EnrollmentWithFirstStageDataEntry = (props: Props) => {
ref={relatedStageRef}
programId={passOnProps.programId}
programStageId={firstStageMetaData.stage?.id}
actionTypesOptions={relatedStageModesOptions}
actionsOptions={relatedStageActionsOptions}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -10,8 +10,8 @@ export type Props = {
formFoundation: RenderFoundation,
programId: string,
relatedStageRef?: { current: ?RelatedStageRefPayload },
relatedStageModesOptions?: {
[key: $Keys<typeof RelatedStageModes>]: {
relatedStageActionsOptions?: {
[key: $Keys<typeof relatedStageActions>]: {
hidden?: boolean,
disabled?: boolean,
disabledMessage?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -69,8 +69,8 @@ export type OwnProps = $ReadOnly<{|
saveButtonText: (trackedEntityName: string) => string,
firstStageMetaData?: ?{ stage: ?ProgramStage },
relatedStageRef?: { current: ?RelatedStageRefPayload },
relatedStageModesOptions?: {
[key: $Keys<typeof RelatedStageModes>]: {
relatedStageActionsOptions?: {
[key: $Keys<typeof relatedStageActions>]: {
hidden?: boolean,
disabled?: boolean,
disabledMessage?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -184,7 +184,7 @@ export const useBuildEnrollmentPayload = ({
},
formHasError,
programStageIdLinkedEventToRedirectTo:
relatedStageLinkedEvent && linkMode === RelatedStageModes.ENTER_DATA
relatedStageLinkedEvent && linkMode === relatedStageActions.ENTER_DATA
? relatedStageLinkedEvent.programStage
: undefined,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -63,7 +63,7 @@ const getAskToCompleteEnrollment = (InnerComponent: ComponentType<any>) => (prop
if (
askCompleteEnrollmentOnEventComplete &&
(isCompleted || saveType === addEventSaveTypes.COMPLETE) &&
linkMode !== RelatedStageModes.ENTER_DATA
linkMode !== relatedStageActions.ENTER_DATA
) {
setOpenCompleteModal(true);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -75,7 +75,7 @@ const getEventDetailsByLinkMode = ({
});
}

if (linkMode === RelatedStageModes.LINK_EXISTING_RESPONSE) {
if (linkMode === relatedStageActions.LINK_EXISTING_RESPONSE) {
const { linkedEventId } = relatedStageDataValues;
return {
linkedEvent: null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { RelatedStageDataValueStates, RelatedStageRelationshipType } from '../../../WidgetRelatedStages';
import { RelatedStageModes } from '../../../WidgetRelatedStages';
import { relatedStageActions } from '../../../WidgetRelatedStages';

type CommonEventDetails = {
event: string,
Expand Down Expand Up @@ -28,7 +28,7 @@ export type LinkedRequestEvent = {
}

export type ConvertedRelatedStageEventProps = {|
linkMode: $Keys<typeof RelatedStageModes>,
linkMode: $Keys<typeof relatedStageActions>,
relatedStageDataValues: RelatedStageDataValueStates,
programId: string,
teiId?: ?string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ 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<OwnProps> = (props) => {
const dispatch = useDispatch();
useEffect(() => () => {
dispatch(cleanUpUid());
}, [dispatch]);

const relatedStageModesOptions = {
[RelatedStageModes.LINK_EXISTING_RESPONSE]: { hidden: true },
const relatedStageActionsOptions = {
[relatedStageActions.LINK_EXISTING_RESPONSE]: { hidden: true },
};

return <EnrollmentRegistrationEntry {...props} relatedStageModesOptions={relatedStageModesOptions} />;
return <EnrollmentRegistrationEntry {...props} relatedStageActionsOptions={relatedStageActionsOptions} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
({
Expand All @@ -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 (
Expand All @@ -45,7 +45,7 @@ const NewEnrollmentRelationshipPlain =
renderDuplicatesDialogActions={renderDuplicatesDialogActions}
renderDuplicatesCardActions={renderDuplicatesCardActions}
ExistingUniqueValueDialogActions={ExistingUniqueValueDialogActions}
relatedStageModesOptions={relatedStageModesOptions}
relatedStageActionsOptions={relatedStageActionsOptions}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
({
Expand All @@ -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 (
Expand All @@ -47,7 +47,7 @@ const NewEnrollmentRelationshipPlain =
renderDuplicatesCardActions={renderDuplicatesCardActions}
ExistingUniqueValueDialogActions={ExistingUniqueValueDialogActions}
trackedEntityInstanceAttributes={inheritedAttributes}
relatedStageModesOptions={relatedStageModesOptions}
relatedStageActionsOptions={relatedStageActionsOptions}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -37,7 +37,7 @@ export const requestSaveEvent = ({
linkedEvent: ?LinkedRequestEvent,
relationship: ?Object,
serverData: Object,
linkMode: ?$Keys<typeof RelatedStageModes>,
linkMode: ?$Keys<typeof relatedStageActions>,
onSaveExternal: ?ExternalSaveHandler,
onSaveSuccessActionType?: string,
onSaveErrorActionType?: string,
Expand All @@ -62,7 +62,7 @@ export const setSaveEnrollmentEventInProgress = ({
requestEventId: string,
linkedEventId: ?string,
linkedOrgUnitId: ?string,
linkMode: ?$Keys<typeof RelatedStageModes>,
linkMode: ?$Keys<typeof relatedStageActions>,
}) => actionCreator(newEventWidgetActionTypes.SET_SAVE_ENROLLMENT_EVENT_IN_PROGRESS)({
requestEventId,
linkedEventId,
Expand Down
Loading

0 comments on commit 0dc2f01

Please sign in to comment.