diff --git a/src/components/form/FormBase.tsx b/src/components/form/FormBase.tsx index 7aa41a8d..93cd4f62 100644 --- a/src/components/form/FormBase.tsx +++ b/src/components/form/FormBase.tsx @@ -1,4 +1,3 @@ -// import { NoticeBox } from '@dhis2/ui' import React, { useMemo } from 'react' import { FormProps, Form as ReactFinalForm } from 'react-final-form' import { @@ -11,7 +10,6 @@ import { useCustomAttributesQuery } from './attributes' type MaybeModelWithAttributes = { id?: string name?: string - factor?: string attributeValues?: PartialAttributeValue[] | undefined } @@ -46,10 +44,6 @@ export function FormBase({ } }, [customAttributes.data, initialValues, includeAttributes]) - // if (customAttributes.error) { - // return - // } - if (!initialValuesWithAttributes || customAttributes.loading) { return } diff --git a/src/lib/sectionList/listViews/sectionListViewsConfig.ts b/src/lib/sectionList/listViews/sectionListViewsConfig.ts index 6c78bf72..6f8ff9e5 100644 --- a/src/lib/sectionList/listViews/sectionListViewsConfig.ts +++ b/src/lib/sectionList/listViews/sectionListViewsConfig.ts @@ -128,12 +128,30 @@ export const modelListViewsConfig = { }, indicator: { columns: { - default: ['name', DESCRIPTORS.publicAccess, 'lastUpdated'], + default: [ + 'name', + { label: i18n.t('Indicator Type'), path: 'indicatorType' }, + DESCRIPTORS.publicAccess, + 'lastUpdated', + ], }, filters: { default: ['indicatorType'], }, }, + indicatorType: { + columns: { + default: [ + 'name', + { label: i18n.t('Factor'), path: 'factor' }, + DESCRIPTORS.publicAccess, + 'lastUpdated', + ], + }, + filters: { + default: [], + }, + }, categoryOptionGroupSet: { columns: { default: [ diff --git a/src/pages/indicatorTypes/Edit.tsx b/src/pages/indicatorTypes/Edit.tsx index b264009c..da6b6f5f 100644 --- a/src/pages/indicatorTypes/Edit.tsx +++ b/src/pages/indicatorTypes/Edit.tsx @@ -28,7 +28,7 @@ export const Component = () => { fields: fieldFilters.concat(), }, } - const IndicatorTypeQuery = useQuery({ + const indicatorTypeQuery = useQuery({ queryKey: [query], queryFn: queryFn, }) @@ -36,7 +36,7 @@ export const Component = () => { diff --git a/src/pages/indicatorTypes/form/IndicatorTypesSchema.ts b/src/pages/indicatorTypes/form/IndicatorTypesSchema.ts index a52e9809..a349d138 100644 --- a/src/pages/indicatorTypes/form/IndicatorTypesSchema.ts +++ b/src/pages/indicatorTypes/form/IndicatorTypesSchema.ts @@ -5,10 +5,7 @@ const { identifiable } = modelFormSchemas export const IndicatorSchema = identifiable.extend({ name: z.string().min(1, 'Name is required'), - factor: z - .string() - .min(1, 'Factor is required') - .regex(/^\d+(\.\d+)?$/, 'Factor must be a valid number'), + factor: z.coerce.number().int(), }) export const initialValues = getDefaults(IndicatorSchema) diff --git a/src/types/generated/models.ts b/src/types/generated/models.ts index af8fd6a7..42d47c20 100644 --- a/src/types/generated/models.ts +++ b/src/types/generated/models.ts @@ -4776,7 +4776,7 @@ export type IndicatorType = { created: string createdBy: User displayName: string - factor: string + factor: number favorite: boolean favorites: Array href: string