Skip to content

Commit

Permalink
Fiks malverdier dokarkiv
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran committed Jan 21, 2025
1 parent 97a30e4 commit 12185e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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)
}
})
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -262,7 +263,6 @@ const DokarkivForm = () => {
)}
</div>
<FormCheckbox name={`dokarkiv.ferdigstill`} label="Ferdigstill journalpost" />
{/*TODO: Felter for digital innsending synes ikke ved bruk av mal*/}
{digitalInnsending ? <Digitalinnsending /> : null}
<VStack gap="4" style={{ margin: '10px 0 15px 0' }}>
<FileUpload.Dropzone
Expand Down

0 comments on commit 12185e3

Please sign in to comment.