Skip to content

Commit

Permalink
fix: filter out user ous from metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Dec 12, 2023
1 parent 20ec39b commit 20de514
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { useCachedDataQuery, convertOuLevelsToUids } from '@dhis2/analytics'
import {
useCachedDataQuery,
convertOuLevelsToUids,
USER_ORG_UNIT,
USER_ORG_UNIT_CHILDREN,
USER_ORG_UNIT_GRANDCHILDREN,
} from '@dhis2/analytics'
import { useDataEngine, useDataMutation } from '@dhis2/app-runtime'
import { CssVariables } from '@dhis2/ui'
import cx from 'classnames'
Expand Down Expand Up @@ -266,8 +272,16 @@ const App = () => {
dispatch(acSetUiOpenDimensionModal(dimensionId))

const onResponsesReceived = (response) => {
const itemsMetadata = Object.entries(response.metaData.items).reduce(
(obj, [id, item]) => {
const itemsMetadata = Object.entries(response.metaData.items)
.filter(
([item]) =>
![
USER_ORG_UNIT,
USER_ORG_UNIT_CHILDREN,
USER_ORG_UNIT_GRANDCHILDREN,
].includes(item)
)
.reduce((obj, [id, item]) => {
obj[id] = {
id,
name: item.name || item.displayName,
Expand All @@ -277,9 +291,7 @@ const App = () => {
}

return obj
},
{}
)
}, {})

dispatch(acAddMetadata(itemsMetadata))
dispatch(acSetVisualizationLoading(false))
Expand Down

0 comments on commit 20de514

Please sign in to comment.