From 696c20fe656716835d0d98e8c44bb95d538a2ccf Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Thu, 2 May 2024 10:46:10 +0200 Subject: [PATCH] fix: skip duplicates reviews --- .../DataEntries/common/TEIAndEnrollment/geometry.js | 2 +- .../DataEntryTrackedEntityInstance.component.js | 1 + .../TrackedEntityInstance/DataEntryTrackedEntityInstance.js | 1 + .../possibleDuplicatesDialog.actions.js | 4 ++++ .../possibleDuplicatesDialog.epics.js | 5 +++++ .../descriptions/possibleDuplicates.reducerDescription.js | 6 ++++++ 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/core_modules/capture-core/components/DataEntries/common/TEIAndEnrollment/geometry.js b/src/core_modules/capture-core/components/DataEntries/common/TEIAndEnrollment/geometry.js index fcc561bebc..b4c9de8da1 100644 --- a/src/core_modules/capture-core/components/DataEntries/common/TEIAndEnrollment/geometry.js +++ b/src/core_modules/capture-core/components/DataEntries/common/TEIAndEnrollment/geometry.js @@ -14,7 +14,7 @@ const standardGeoJson = (geometry: Array | { longitude: number, latitude export const geometryType = (formValuesKey: Object) => Object.values(FEATURETYPE).find(geometryKey => geometryKey === formValuesKey); -export const getPossibleTetFeatureTypeKey = (serverValues: Object) => +export const getPossibleTetFeatureTypeKey = (serverValues: Object = {}) => Object.keys(serverValues).find(key => key.startsWith('FEATURETYPE_')); export const buildGeometryProp = (key: string, serverValues: Object) => { diff --git a/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/DataEntry/TrackedEntityInstance/DataEntryTrackedEntityInstance.component.js b/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/DataEntry/TrackedEntityInstance/DataEntryTrackedEntityInstance.component.js index baf4bd3e05..8b0ce245fc 100644 --- a/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/DataEntry/TrackedEntityInstance/DataEntryTrackedEntityInstance.component.js +++ b/src/core_modules/capture-core/components/Pages/NewRelationship/RegisterTei/DataEntry/TrackedEntityInstance/DataEntryTrackedEntityInstance.component.js @@ -41,6 +41,7 @@ const RelationshipTrackedEntityInstancePlain = renderDuplicatesDialogActions={renderDuplicatesDialogActions} renderDuplicatesCardActions={renderDuplicatesCardActions} ExistingUniqueValueDialogActions={ExistingUniqueValueDialogActions} + orgUnit={{ id: orgUnitId }} /> ); }; diff --git a/src/core_modules/capture-core/components/Pages/common/TEIRelationshipsWidget/RegisterTei/DataEntry/TrackedEntityInstance/DataEntryTrackedEntityInstance.js b/src/core_modules/capture-core/components/Pages/common/TEIRelationshipsWidget/RegisterTei/DataEntry/TrackedEntityInstance/DataEntryTrackedEntityInstance.js index 0680da0fa1..5fb262ae08 100644 --- a/src/core_modules/capture-core/components/Pages/common/TEIRelationshipsWidget/RegisterTei/DataEntry/TrackedEntityInstance/DataEntryTrackedEntityInstance.js +++ b/src/core_modules/capture-core/components/Pages/common/TEIRelationshipsWidget/RegisterTei/DataEntry/TrackedEntityInstance/DataEntryTrackedEntityInstance.js @@ -49,6 +49,7 @@ const RelationshipTrackedEntityInstancePlain = renderDuplicatesDialogActions={renderDuplicatesDialogActions} renderDuplicatesCardActions={renderDuplicatesCardActions} ExistingUniqueValueDialogActions={ExistingUniqueValueDialogActions} + orgUnit={{ id: orgUnitId }} /> ); }; diff --git a/src/core_modules/capture-core/components/PossibleDuplicatesDialog/possibleDuplicatesDialog.actions.js b/src/core_modules/capture-core/components/PossibleDuplicatesDialog/possibleDuplicatesDialog.actions.js index c92923d54a..3aac922aec 100644 --- a/src/core_modules/capture-core/components/PossibleDuplicatesDialog/possibleDuplicatesDialog.actions.js +++ b/src/core_modules/capture-core/components/PossibleDuplicatesDialog/possibleDuplicatesDialog.actions.js @@ -6,6 +6,7 @@ export const actionTypes = { DUPLICATES_REVIEW: 'PossibleDuplicatesReview', DUPLICATES_REVIEW_RETRIEVAL_SUCCESS: 'PossibleDuplicatesReviewRetrievalSuccess', DUPLICATES_REVIEW_RETRIEVAL_FAILED: 'PossibleDuplicatesReviewRetrievalFailed', + DUPLICATES_REVIEW_SKIPPED: 'PossibleDuplicatesReview.Skipped', DUPLICATES_REVIEW_CHANGE_PAGE: 'PossibleDuplicatesChangePage', DUPLICATES_RESET: 'PossibleDuplicatesReset', }; @@ -30,6 +31,9 @@ export const reviewDuplicates = ({ export const duplicatesForReviewRetrievalSuccess = (teis: Array, currentPage: number) => actionCreator(actionTypes.DUPLICATES_REVIEW_RETRIEVAL_SUCCESS)({ teis, currentPage }); +export const duplicatesReviewSkipped = () => + actionCreator(actionTypes.DUPLICATES_REVIEW_SKIPPED)(); + export const duplicatesForReviewRetrievalFailed = () => actionCreator(actionTypes.DUPLICATES_REVIEW_RETRIEVAL_FAILED)(); diff --git a/src/core_modules/capture-core/components/PossibleDuplicatesDialog/possibleDuplicatesDialog.epics.js b/src/core_modules/capture-core/components/PossibleDuplicatesDialog/possibleDuplicatesDialog.epics.js index 78098fa714..06ef99576a 100644 --- a/src/core_modules/capture-core/components/PossibleDuplicatesDialog/possibleDuplicatesDialog.epics.js +++ b/src/core_modules/capture-core/components/PossibleDuplicatesDialog/possibleDuplicatesDialog.epics.js @@ -7,6 +7,7 @@ import { actionTypes, duplicatesForReviewRetrievalSuccess, duplicatesForReviewRetrievalFailed, + duplicatesReviewSkipped, } from './possibleDuplicatesDialog.actions'; import { scopeTypes, getScopeFromScopeId, EventProgram, TrackerProgram, TrackedEntityType, dataElementTypes, @@ -70,6 +71,10 @@ export const loadSearchGroupDuplicatesForReviewEpic = ( }) .filter(f => f); + if (filters.length === 0) { + return Promise.resolve(duplicatesReviewSkipped()); + } + const contextParam = scopeType === scopeTypes.TRACKER_PROGRAM ? { program: selectedScopeId } : { trackedEntityType: selectedScopeId }; const queryArgs = { ouMode: 'ACCESSIBLE', diff --git a/src/core_modules/capture-core/reducers/descriptions/possibleDuplicates.reducerDescription.js b/src/core_modules/capture-core/reducers/descriptions/possibleDuplicates.reducerDescription.js index 6d196eb02b..611eef3e85 100644 --- a/src/core_modules/capture-core/reducers/descriptions/possibleDuplicates.reducerDescription.js +++ b/src/core_modules/capture-core/reducers/descriptions/possibleDuplicates.reducerDescription.js @@ -23,6 +23,12 @@ export const possibleDuplicatesDesc = createReducerDescription({ loadError: false, currentPage: action.payload.currentPage, }), + [searchGroupDuplicateActionTypes.DUPLICATES_REVIEW_SKIPPED]: state => ({ + ...state, + isLoading: false, + isUpdating: false, + loadError: false, + }), [searchGroupDuplicateActionTypes.DUPLICATES_REVIEW_RETRIEVAL_FAILED]: state => ({ ...state, isLoading: false,