From b611b0840fae1f9e5aa5cb45badd33c2396ccef4 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Wed, 9 Oct 2024 09:58:05 +0200 Subject: [PATCH] fix: use linkedEntityFormFoundation instead of the searchFormFoundation --- .../TeiRelationshipSearchResults.component.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/core_modules/capture-core/components/Pages/NewRelationship/TeiRelationship/SearchResults/TeiRelationshipSearchResults.component.js b/src/core_modules/capture-core/components/Pages/NewRelationship/TeiRelationship/SearchResults/TeiRelationshipSearchResults.component.js index 3cced06ccf..461424f302 100644 --- a/src/core_modules/capture-core/components/Pages/NewRelationship/TeiRelationship/SearchResults/TeiRelationshipSearchResults.component.js +++ b/src/core_modules/capture-core/components/Pages/NewRelationship/TeiRelationship/SearchResults/TeiRelationshipSearchResults.component.js @@ -10,7 +10,11 @@ import { makeAttributesSelector } from './teiRelationshipSearchResults.selectors import { CardList } from '../../../../CardList'; import type { CurrentSearchTerms } from '../../../../SearchBox'; import { SearchResultsHeader } from '../../../../SearchResultsHeader'; -import { type SearchGroup } from '../../../../../metaData'; +import { + type SearchGroup, + getTrackerProgramThrowIfNotFound, + getTrackedEntityTypeThrowIfNotFound, +} from '../../../../../metaData'; import { ResultsPageSizeContext } from '../../../shared-contexts'; import type { ListItem } from '../../../../CardList/CardList.types'; import { convertClientValuesToServer } from '../../../../../converters/helpers/clientToServer'; @@ -25,7 +29,8 @@ type Props = {| currentPage: number, searchGroup: SearchGroup, searchValues: any, - selectedProgramId: string, + selectedProgramId?: string, + selectedTrackedEntityTypeId: string, teis: Array, trackedEntityTypeName: string, ...CssClasses @@ -60,6 +65,15 @@ const getStyles = (theme: Theme) => ({ }, }); +const getLinkedEntityFormFoundation = (selectedProgramId, selectedTrackedEntityTypeId) => { + if (selectedProgramId) { + const program = getTrackerProgramThrowIfNotFound(selectedProgramId); + return program.enrollment.enrollmentForm; + } + const trackedEntityType = getTrackedEntityTypeThrowIfNotFound(selectedTrackedEntityTypeId); + return trackedEntityType.teiRegistration.form; +}; + const CardListButton = ({ handleOnClick, teiId }) => (