Skip to content

Commit

Permalink
Diverse bugfix, inkludert ameldingform som tidvis satte fradato til 1…
Browse files Browse the repository at this point in the history
…970 under form input

#deploy-test-frontend
  • Loading branch information
stigus committed Jan 17, 2024
1 parent 8771bb7 commit b2fe20c
Show file tree
Hide file tree
Showing 21 changed files with 105 additions and 92 deletions.
106 changes: 48 additions & 58 deletions apps/dolly-frontend/src/main/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/dolly-frontend/src/main/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@hookform/error-message": "^2.0.1",
"@navikt/ds-css": "^5.0.3",
"@navikt/ds-icons": "^3.4.3",
"@navikt/ds-react": "^5.0.3",
"@navikt/ds-react": "^5.15.0",
"@redux-devtools/extension": "^3.2.3",
"@reduxjs/toolkit": "^1.8.4",
"@rollup/plugin-terser": "^0.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BrregPanel.initialValues = ({ set, del, has }) => ({
foretaksNavn: {
navn1: '',
},
orgNr: '',
orgNr: null,
personroller: [],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react'
import styled from 'styled-components'
import useBoolean from '@/utils/hooks/useBoolean'
import * as _ from 'lodash'
import { add, eachMonthOfInterval, format, isDate } from 'date-fns'
import { add, eachMonthOfInterval, format, isAfter, isDate } from 'date-fns'
import { DollySelect } from '@/components/ui/form/inputs/select/Select'
import { ArbeidKodeverk } from '@/config/kodeverk'
import NavButton from '@/components/ui/button/NavButton/NavButton'
Expand Down Expand Up @@ -63,15 +63,19 @@ export const AmeldingForm = ({ warningMessage }: AmeldingFormProps): JSX.Element

const handlePeriodeChange = (dato: string, type: string) => {
const fixedDato = fixTimezone(dato)
formMethods.setValue(`aareg[0].genererPeriode.${type}`, fixedDato)
formMethods.setValue(`aareg[0].genererPeriode.${type}`, fixedDato, { shouldTouch: true })

if ((type === 'tom' && fom) || (type === 'fom' && tom)) {
const maanederPrev: Array<Amelding> = formMethods.watch(paths.amelding)
const maaneder: Array<string> = []
const maanederTmp = eachMonthOfInterval({
start: new Date(type === 'fom' ? dato : fomDate),
end: new Date(type === 'tom' ? dato : tomDate),
})
const startDate = dato && new Date(type === 'fom' ? dato : fomDate)
const endDate = dato && new Date(type === 'tom' ? dato : tomDate)
const maanederTmp = isAfter(endDate, startDate)
? eachMonthOfInterval({
start: startDate,
end: endDate,
})
: []
maanederTmp.forEach((maaned) => {
maaneder.push(format(maaned, 'yyyy-MM'))
})
Expand Down Expand Up @@ -102,7 +106,7 @@ export const AmeldingForm = ({ warningMessage }: AmeldingFormProps): JSX.Element
})
}
}
formMethods.trigger()
formMethods.trigger('aareg')
}

const handleArbeidsforholdstypeChange = (event: KodeverkValue) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ export const ArbeidsforholdToggle = (): ReactElement => {
const handleToggleChange = (value: ArbeidsgiverTyper) => {
setTypeArbeidsgiver(value)
if (value === ArbeidsgiverTyper.privat) {
formMethods.setValue('aareg', [initialAaregPers])
formMethods.resetField('aareg', { defaultValue: [initialAaregPers] })
} else if (value === ArbeidsgiverTyper.felles || value === ArbeidsgiverTyper.fritekst) {
formMethods.setValue('aareg', [initialAaregOrg])
formMethods.resetField('aareg', { defaultValue: [initialAaregOrg] })
} else if (value === ArbeidsgiverTyper.egen) {
formMethods.setValue('aareg', [initialValues])
formMethods.resetField('aareg', { defaultValue: [initialValues] })
}
formMethods.trigger('aareg')
formMethods.clearErrors('aareg')
}

const warningMessage = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const initialValues = {
foretaksNavn: {
navn1: '',
},
orgNr: '',
orgNr: null,
personroller: [],
}

Expand Down Expand Up @@ -49,6 +49,7 @@ export const EnheterForm = ({ formMethods }) => {
}

formMethods.setValue(path, currentValues)
formMethods.trigger(path)
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const OrgnrToggle = ({
if (oldValues.hasOwnProperty('postAdresse')) {
delete oldValues['postAdresse']
}
oldValues['orgNr'] = ''
oldValues['orgNr'] = null
formMethods.setValue(path, oldValues)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const OrgnummerToggle = ({ formMethods, opplysningspliktigPath, path }: P
setInputType(value)
sessionStorage.setItem(ORGANISASJONSTYPE_TOGGLE, value)
formMethods.setValue(path, '')
formMethods.clearErrors(path)
}

const handleChange = (value: { juridiskEnhet: string; orgnr: string }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const KrrstubForm = () => {
} else {
formMethods.setValue('krrstub.registrert', true)
}
formMethods.trigger('krrstub')
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ export const Kontakt = ({ formMethods, path, eksisterendeNyPerson = null }: Kont
size="xlarge"
placeholder={getPlaceholder(formMethods.getValues(), `${personPath}.navn`)}
isLoading={loading}
onChange={(navn: string) => setNavn(navn, `${personPath}.navn`, formMethods.setValue)}
onChange={(navn: string) => {
setNavn(navn, `${personPath}.navn`, formMethods.setValue)
formMethods.setValue(`${personPath}.identifikasjonsnummer`, undefined)
formMethods.trigger(personPath)
}}
value={formMethods.watch(`${personPath}.navn.fornavn`)}
isDisabled={disablePersoninfo}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ export const PdlEksisterendePerson = ({
{filteredOptions?.length > 0 ? (
<FormikSelect
name={eksisterendePersonPath}
onChange={(person) => {
formMethods.setValue(eksisterendePersonPath, person?.value || null)
formMethods.trigger('pdldata.person.kontaktinformasjonForDoedsbo')
}}
label={label}
options={filteredOptions}
size={'xlarge'}
Expand Down
Loading

0 comments on commit b2fe20c

Please sign in to comment.