diff --git a/packages/bygger/src/translations/utils.ts b/packages/bygger/src/translations/utils.ts index 65fe06693..5fbbe893d 100644 --- a/packages/bygger/src/translations/utils.ts +++ b/packages/bygger/src/translations/utils.ts @@ -7,6 +7,8 @@ import { } from '@navikt/skjemadigitalisering-shared-components'; import { + AccordionSettingValue, + AccordionSettingValues, AttachmentSettingValue, AttachmentSettingValues, Component, @@ -133,6 +135,7 @@ const getTranslatablePropertiesFromForm = (form: NavFormType) => addAnother, removeAnother, attachmentValues, + accordionValues, }) => ({ title, label: getLabel(label, type, !!hideLabel), @@ -150,6 +153,7 @@ const getTranslatablePropertiesFromForm = (form: NavFormType) => addAnother: getTextFromComponentProperty(addAnother), removeAnother: getTextFromComponentProperty(removeAnother), attachmentValues: getAttachmentTexts(attachmentValues), + accordionValues: getAccordionTexts(accordionValues), }), ); @@ -164,6 +168,16 @@ const textObject = (withInputType: boolean, value: string): TextObjectType => { }; }; +const getAccordionTexts = (accordionValues?: AccordionSettingValues): undefined | string[] => { + if (!accordionValues) { + return undefined; + } + + return accordionValues.flatMap((value: AccordionSettingValue) => { + return [value.title, value.content]; + }); +}; + const getAttachmentTexts = (attachmentValues?: AttachmentSettingValues): undefined | string[] => { if (!attachmentValues) { return undefined; @@ -193,7 +207,7 @@ const getFormTexts = (form?: NavFormType, withInputType = false): TextObjectType Object.keys(component) .filter((key) => component[key] !== undefined && key !== 'attachmentValues') .flatMap((key) => { - if (key === 'values' || key === 'data') { + if (key === 'values' || key === 'data' || key === 'accordionValues') { return component[key] .filter((value) => value !== '') .map((value) => textObject(withInputType, value)) as TextObjectType; diff --git a/packages/shared-components/src/formio/components/core/accordion/Accordion.tsx b/packages/shared-components/src/formio/components/core/accordion/Accordion.tsx index 515b29aaa..f31802e05 100644 --- a/packages/shared-components/src/formio/components/core/accordion/Accordion.tsx +++ b/packages/shared-components/src/formio/components/core/accordion/Accordion.tsx @@ -10,6 +10,7 @@ class Accordion extends BaseComponent { label: 'Trekkspill', type: 'accordion', key: 'accordion', + hideLabel: true, }); } @@ -34,9 +35,9 @@ class Accordion extends BaseComponent { this.setReactInstance(ref)} headingSize={this.getTitleSize()}> {this.getAccordionValues()?.map((item, index) => ( - {item.title} + {this.translate(item.title)} - + ))} diff --git a/packages/shared-domain/src/index.ts b/packages/shared-domain/src/index.ts index 72f14240c..836369c6f 100644 --- a/packages/shared-domain/src/index.ts +++ b/packages/shared-domain/src/index.ts @@ -1,3 +1,4 @@ +import { AccordionSettingValue, AccordionSettingValues } from './accordion'; import attachmentUtils, { AttachmentSettingValue, AttachmentSettingValues, @@ -125,6 +126,8 @@ export { validatorUtils, }; export type { + AccordionSettingValue, + AccordionSettingValues, AktivitetPeriode, AktivitetVedtaksinformasjon, AttachmentSettingValue,