From 3b9134d25e2542041f257d0d23b1aaacfa6dadf9 Mon Sep 17 00:00:00 2001 From: Henrique Moreira <98126579+henriquemoreiraa@users.noreply.github.com> Date: Mon, 6 Mar 2023 17:55:46 -0300 Subject: [PATCH] fix: not set org filter (#1025) * fix: not set org filter * fix: org not set import * fix: org not set null --- src/common/utils.js | 9 ++++++--- src/components/CaptureFilter.js | 1 + src/context/GrowerContext.js | 6 +----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/utils.js b/src/common/utils.js index c2f5f43b3..9d61fb65c 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -27,15 +27,18 @@ export const setOrganizationFilter = (filter, userOrgId, orgList) => { ) { // don't filter if userOrgId is null so that we include both null and not null org ids in results filter.organization_id = undefined; + } else if ( + filter.organization_id === ORGANIZATION_NOT_SET || + filter.organization_id === null + ) { + // if filtering for items without an org id, filter for null + filter.organization_id = null; } else if ( filter.organization_id && typeof filter.organization_id === 'string' ) { // if filtering by one org id, format in array for api query filter.organization_id = [filter.organization_id]; - } else if (filter.organization_id === ORGANIZATION_NOT_SET) { - // if filtering for items without an org id, filter for null - filter.organization_id = null; } else { filter.organization_id = undefined; } diff --git a/src/components/CaptureFilter.js b/src/components/CaptureFilter.js index 9825864da..623fe3d63 100644 --- a/src/components/CaptureFilter.js +++ b/src/components/CaptureFilter.js @@ -108,6 +108,7 @@ function Filter(props) { function handleSubmit(e) { e.preventDefault(); + // save the filer to context for editing & submit const test = { uuid: uuid.trim(), diff --git a/src/context/GrowerContext.js b/src/context/GrowerContext.js index 2b184537b..ed96a086b 100644 --- a/src/context/GrowerContext.js +++ b/src/context/GrowerContext.js @@ -69,11 +69,7 @@ export function GrowerProvider(props) { const pageNumber = currentPage; //set correct values for organization_id, an array of uuids for ALL_ORGANIZATIONS or a uuid string if provided - const finalFilter = setOrganizationFilter( - filter.getWhereObj(), - orgId, - orgList - ); + const finalFilter = setOrganizationFilter(filter, orgId, orgList); log.debug('load growers');