Skip to content

Commit

Permalink
fix: not set org filter (Greenstand#1025)
Browse files Browse the repository at this point in the history
* fix: not set org filter

* fix: org not set import

* fix: org not set null
  • Loading branch information
henriquemoreiraa authored Mar 6, 2023
1 parent d8874f4 commit 3b9134d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/CaptureFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 1 addition & 5 deletions src/context/GrowerContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit 3b9134d

Please sign in to comment.