From 12185e39b1287f97a173d2d48e1b277e021b4abb Mon Sep 17 00:00:00 2001 From: Betsy Carina Traran Date: Tue, 21 Jan 2025 16:14:24 +0100 Subject: [PATCH] Fiks malverdier dokarkiv --- .../bestillingsveileder/options/malOptions.tsx | 15 +++++++++++++++ .../fagsystem/dokarkiv/form/DokarkivForm.tsx | 14 +++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/options/malOptions.tsx b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/options/malOptions.tsx index ebd28209b41..c31e178cbd1 100644 --- a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/options/malOptions.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/options/malOptions.tsx @@ -91,6 +91,9 @@ export const initialValuesBasedOnMal = (mal: any, environments: any) => { ) delete initialValuesMal.tpsMessaging.utenlandskBankkonto } + if (initialValuesMal.dokarkiv) { + initialValuesMal.dokarkiv = getUpdatedDokarkiv(initialValuesMal.dokarkiv) + } initialValuesMal.environments = filterMiljoe(environments, mal.bestilling?.environments) return initialValuesMal @@ -448,6 +451,18 @@ const updateKontaktType = (kontaktinfo: any) => { return kontaktinfo } +const getUpdatedDokarkiv = (dokarkiv: any) => { + let newDokarkiv = Object.assign({}, dokarkiv) + if (newDokarkiv.avsenderMottaker) { + newDokarkiv.avsenderMottaker = { + id: newDokarkiv.avsenderMottaker?.id || '', + navn: newDokarkiv.avsenderMottaker?.navn || '', + idType: newDokarkiv.avsenderMottaker?.idType || '', + } + } + return newDokarkiv +} + const updateData = (data: any, initalValues: any) => { let newData = Object.assign({}, data) newData = _.extend({}, initalValues, newData) diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/dokarkiv/form/DokarkivForm.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/dokarkiv/form/DokarkivForm.tsx index 4407a1e3d62..a9934bfc33b 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/dokarkiv/form/DokarkivForm.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/dokarkiv/form/DokarkivForm.tsx @@ -107,8 +107,8 @@ const DokarkivForm = () => { )?.tittel vedleggFraMal.push({ file: new File([malDokument.contents], fileName, { type: 'application/pdf' }), - error: false, //TODO: Test med faila dokument - reasons: [], //TODO: Test med faila dokument + error: false, + reasons: [], }) }) setVedlegg([...vedleggFraMal, ...vedlegg]) @@ -134,6 +134,9 @@ const DokarkivForm = () => { formMethods.setValue('dokarkiv.skjema', skjema) formMethods.watch('dokarkiv.dokumenter')?.forEach((dokument: any, idx: number) => { formMethods.setValue(`dokarkiv.dokumenter[${idx}].brevkode`, skjema.value) + if (!dokument?.tittel) { + formMethods.setValue(`dokarkiv.dokumenter[${idx}].tittel`, skjema.data) + } }) } @@ -185,10 +188,8 @@ const DokarkivForm = () => { formMethods.trigger('dokarkiv.dokumenter') } - console.log('vedlegg: ', vedlegg) //TODO - SLETT MEG - console.log('dokumenter: ', dokumenter) //TODO - SLETT MEG - - //TODO: Handle error-filer, se aksel-dok + // console.log('vedlegg: ', vedlegg) //TODO - SLETT MEG + // console.log('dokumenter: ', dokumenter) //TODO - SLETT MEG return ( // @ts-ignore @@ -262,7 +263,6 @@ const DokarkivForm = () => { )} - {/*TODO: Felter for digital innsending synes ikke ved bruk av mal*/} {digitalInnsending ? : null}