(
'dataElements/gist',
@@ -45,16 +33,27 @@ export const Component = () => {
fields: filterFields.concat(),
...initialParams,
},
- // refetched on mount by useSectionListParamsRefetch below
+ // refetched on mount by effect below
{ lazy: true }
)
- useSectionListParamsRefetch(refetch)
+ useEffect(() => {
+ // wait to fetch until selected-columns are loaded
+ // so we dont fetch data multiple times
+ if (listViewQuery.isLoading) {
+ return
+ }
+ refetch({
+ ...initialParams,
+ fields: columns
+ .map((column) => getFieldFilterFromPath(column.path, 0))
+ .concat('id'),
+ })
+ }, [refetch, initialParams, columns, listViewQuery.isLoading])
return (
diff --git a/src/pages/dataElements/New.tsx b/src/pages/dataElements/New.tsx
index a6ddf2ea..0a352f2f 100644
--- a/src/pages/dataElements/New.tsx
+++ b/src/pages/dataElements/New.tsx
@@ -6,8 +6,7 @@ import React, { useEffect, useRef } from 'react'
import { Form } from 'react-final-form'
import { useNavigate } from 'react-router-dom'
import { StandardFormActions, StandardFormSection } from '../../components'
-import { SCHEMA_SECTIONS } from '../../constants'
-import { getSectionPath } from '../../lib'
+import { SCHEMA_SECTIONS, getSectionPath } from '../../lib'
import { Attribute } from '../../types/generated'
import { DataElementFormFields, useCustomAttributesQuery } from './form'
import { FormValues } from './form/types'
diff --git a/src/pages/dataElements/form/customFields.tsx b/src/pages/dataElements/form/customFields.tsx
index 57811fc5..757850e2 100644
--- a/src/pages/dataElements/form/customFields.tsx
+++ b/src/pages/dataElements/form/customFields.tsx
@@ -16,8 +16,12 @@ import {
OptionSetSelect,
LegendSetTransfer,
} from '../../../components'
-import { AGGREGATION_TYPE, DOMAIN_TYPE, VALUE_TYPE } from '../../../constants'
-import { useSchemas } from '../../../lib'
+import {
+ AGGREGATION_TYPE,
+ DOMAIN_TYPE,
+ VALUE_TYPE,
+ useSchemas,
+} from '../../../lib'
import classes from './customFields.module.css'
import { EditableFieldWrapper } from './EditableFieldWrapper'
diff --git a/src/pages/overview/Categories.tsx b/src/pages/overview/Categories.tsx
index d4763fe4..a881d4b3 100644
--- a/src/pages/overview/Categories.tsx
+++ b/src/pages/overview/Categories.tsx
@@ -1,6 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import React from 'react'
-import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../constants'
+import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../lib'
import { FilterAuthorizedSections, SummaryCard, SummaryCardGroup } from './card'
import { OverviewGroup, OverviewGroupSummary } from './group'
diff --git a/src/pages/overview/DataElements.tsx b/src/pages/overview/DataElements.tsx
index b9ee2cc6..575ee41b 100644
--- a/src/pages/overview/DataElements.tsx
+++ b/src/pages/overview/DataElements.tsx
@@ -1,6 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import React from 'react'
-import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../constants'
+import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../lib'
import { FilterAuthorizedSections, SummaryCard, SummaryCardGroup } from './card'
import { OverviewGroup, OverviewGroupSummary } from './group'
diff --git a/src/types/section.ts b/src/types/section.ts
index a00d0000..2a5c95e7 100644
--- a/src/types/section.ts
+++ b/src/types/section.ts
@@ -1,4 +1,4 @@
-import type { OverviewSectionName } from '../constants'
+import type { OverviewSectionName } from '../lib'
import { SchemaAuthorities, SchemaName } from './schemaBase'
export interface SectionBase {
diff --git a/yarn.lock b/yarn.lock
index f9181ce3..9a9247c9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -14793,6 +14793,11 @@ zip-stream@^2.1.2:
compress-commons "^2.1.1"
readable-stream "^3.4.0"
+zod@^3.22.2:
+ version "3.22.2"
+ resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.2.tgz#3add8c682b7077c05ac6f979fea6998b573e157b"
+ integrity sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg==
+
zustand@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.4.0.tgz#13b3e8ca959dd53d536034440aec382ff91b65c3"