From 9b26d4775bfeaa77d3b27b42014d1fee8e295188 Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Tue, 24 Oct 2023 14:13:31 +0300 Subject: [PATCH] fix(form): add no value to custom attribute optionset --- src/pages/dataElements/form/CustomAttributes.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/dataElements/form/CustomAttributes.tsx b/src/pages/dataElements/form/CustomAttributes.tsx index 0d422fe4..206c32b4 100644 --- a/src/pages/dataElements/form/CustomAttributes.tsx +++ b/src/pages/dataElements/form/CustomAttributes.tsx @@ -18,16 +18,25 @@ type CustomAttributeProps = { index: number } +type DisplayOptions = Array<{ + value: string | undefined + label: string +}> + function CustomAttribute({ attribute, index }: CustomAttributeProps) { const name = `attributeValues[${index}].value` if (attribute.optionSet?.options) { - const options = attribute.optionSet?.options.map( + let options: DisplayOptions = [ + { value: undefined, label: i18n.t('') }, + ] + const mappedOptions = attribute.optionSet.options.map( ({ code, displayName }) => ({ value: code, label: displayName, }) ) + options = options.concat(mappedOptions) return (