diff --git a/src/pages/indicatorTypes/form/FactorField.tsx b/src/pages/indicatorTypes/form/FactorField.tsx new file mode 100644 index 00000000..cf6c3b53 --- /dev/null +++ b/src/pages/indicatorTypes/form/FactorField.tsx @@ -0,0 +1,28 @@ +import i18n from '@dhis2/d2-i18n' +import { InputFieldFF } from '@dhis2/ui' +import React from 'react' +import { useField } from 'react-final-form' +import { useSchemaSectionHandleOrThrow } from '../../../lib' +import { useValidator } from '../../../lib/models/useFieldValidators' + +export const FactorField = () => { + const fieldName = 'factor' + const schemaSection = useSchemaSectionHandleOrThrow() + const validate = useValidator({ schemaSection, property: 'factor' }) + + const { input, meta } = useField(fieldName, { + validate, + type: 'number', + format: (value) => value?.toString(), + }) + + return ( + + ) +} diff --git a/src/pages/indicatorTypes/form/IndicatorTypesFormFields.tsx b/src/pages/indicatorTypes/form/IndicatorTypesFormFields.tsx index 09b6d5ab..67659c6b 100644 --- a/src/pages/indicatorTypes/form/IndicatorTypesFormFields.tsx +++ b/src/pages/indicatorTypes/form/IndicatorTypesFormFields.tsx @@ -1,7 +1,5 @@ import i18n from '@dhis2/d2-i18n' -import { InputFieldFF } from '@dhis2/ui' import React from 'react' -import { Field } from 'react-final-form' import { CustomAttributesSection, StandardFormField, @@ -11,14 +9,12 @@ import { NameField, } from '../../../components' import { SECTIONS_MAP, useSchemaSectionHandleOrThrow } from '../../../lib' -import { useValidator } from '../../../lib/models/useFieldValidators' +import { FactorField } from './FactorField' export const IndicatorTypesFormFields = () => { const section = SECTIONS_MAP.indicatorType const schemaSection = useSchemaSectionHandleOrThrow() - const validateFactor = useValidator({ schemaSection, property: 'factor' }) - return ( <> @@ -36,15 +32,7 @@ export const IndicatorTypesFormFields = () => { - +