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 6eff575ea5..e0db0b6a92 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 @@ -1,12 +1,11 @@ // @flow import type { Node } from 'react'; import type { OrgUnit } from '@dhis2/rules-engine-javascript'; -import type { RegistrationFormMetadata } from '../common/TEIAndEnrollment/useMetadataForRegistrationForm/types'; import type { RenderCustomCardActions } from '../../CardList'; import type { SaveForDuplicateCheck } from '../common/TEIAndEnrollment/DuplicateCheckOnSave'; import type { ExistingUniqueValueDialogActionsComponent } from '../withErrorMessagePostProcessor'; import type { InputAttribute } from './hooks/useFormValues'; -import { RenderFoundation, ProgramStage } from '../../../metaData'; +import { RenderFoundation, ProgramStage, Enrollment } from '../../../metaData'; import type { RelatedStageRefPayload } from '../../WidgetRelatedStages'; import { relatedStageActions } from '../../WidgetRelatedStages'; @@ -67,7 +66,7 @@ export type OwnProps = $ReadOnly<{| skipDuplicateCheck?: ?boolean, trackedEntityInstanceAttributes?: Array, saveButtonText: (trackedEntityName: string) => string, - firstStageMetaData?: ?{ stage: ?ProgramStage }, + firstStageMetaData?: ?{ stage: ProgramStage }, relatedStageRef?: { current: ?RelatedStageRefPayload }, relatedStageActionsOptions?: { [key: $Keys]: { @@ -85,8 +84,8 @@ type ContainerProps = {| onCancel: () => void, isUserInteractionInProgress: boolean, isSavingInProgress: boolean, - enrollmentMetadata: RegistrationFormMetadata, - formFoundation: ?RenderFoundation, + enrollmentMetadata: Enrollment, + formFoundation: RenderFoundation, formId: ?string, saveButtonText: string, |}; 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 af35348fc9..0c73a5a731 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 @@ -174,15 +174,21 @@ const LinkExistingResponse = ({ ); }; -const LinkButton = withStyles(styles)(({ onLink, label, loading, classes }) => ( - onLink ? ( +const LinkButton = withStyles(styles)(({ onLink, label, saveAttempted, errorMessages, classes }) => { + if (!onLink) { + return null; + } + + const disabled = saveAttempted && Object.values(errorMessages).filter(Boolean).length !== 0; + + return (
-
- ) : null -)); + ); +}); const RelatedStagesActionsPlain = ({ classes, @@ -275,7 +281,12 @@ const RelatedStagesActionsPlain = ({ saveAttempted={saveAttempted} errorMessages={errorMessages} /> - + )} @@ -288,7 +299,12 @@ const RelatedStagesActionsPlain = ({ saveAttempted={saveAttempted} errorMessages={errorMessages} /> - + )} @@ -302,7 +318,12 @@ const RelatedStagesActionsPlain = ({ errorMessages={errorMessages} saveAttempted={saveAttempted} /> - + )}