diff --git a/src/lib/constants/categoryConstants.ts b/src/lib/constants/categoryConstants.ts new file mode 100644 index 00000000..7c9b1f7f --- /dev/null +++ b/src/lib/constants/categoryConstants.ts @@ -0,0 +1,12 @@ +/* Might seem wrong to hardcode this, but it makes things simpler + these IDs are hardcoded in the backend + see + https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultCategoryService.java#L472 + and + https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-services/dhis-service-administration/src/main/resources/data-integrity-checks/categories/categories_one_default_category_combo.yaml + */ + +export const DEFAULT_CATEGORY_OPTION_ID = 'xYerKDKCefk' +export const DEFAULT_CATEGORY_ID = 'GLevLNI9wkl' +export const DEFAULT_CATEGORY_COMBO_ID = 'bjDvmb4bfuf' +export const DEFAULT_CATEGORY_OPTION_COMBO_ID = 'HllvX50cXC0' diff --git a/src/lib/constants/index.ts b/src/lib/constants/index.ts index 369de77f..65f587c2 100644 --- a/src/lib/constants/index.ts +++ b/src/lib/constants/index.ts @@ -2,3 +2,4 @@ export * from './sectionListViewsConfig' export * from './sections' export * from './translatedModelConstants' export * from './translatedModelProperties' +export * from './categoryConstants' diff --git a/src/pages/dataElements/New.tsx b/src/pages/dataElements/New.tsx index a70faabe..6f90422a 100644 --- a/src/pages/dataElements/New.tsx +++ b/src/pages/dataElements/New.tsx @@ -6,7 +6,12 @@ import React, { useEffect, useMemo, useRef } from 'react' import { Form } from 'react-final-form' import { useNavigate } from 'react-router-dom' import { StandardFormActions, StandardFormSection } from '../../components' -import { SCHEMA_SECTIONS, getSectionPath, useSchemas } from '../../lib' +import { + DEFAULT_CATEGORY_COMBO_ID, + SCHEMA_SECTIONS, + getSectionPath, + useSchemas, +} from '../../lib' import { Attribute } from '../../types/generated' import { DataElementFormFields, @@ -44,7 +49,7 @@ function useInitialValues(customAttributes: Attribute[]) { aggregationType: schemas.dataElement.properties.aggregationType.constants?.[0], style: { icon: '', color: '' }, - categoryCombo: { id: '' }, + categoryCombo: { id: DEFAULT_CATEGORY_COMBO_ID }, optionSet: { id: '' }, commentOptionSet: { id: '' }, legendSets: [],