diff --git a/apps/dolly-frontend/src/main/js/package-lock.json b/apps/dolly-frontend/src/main/js/package-lock.json index 702969b56d1..6060c67613d 100644 --- a/apps/dolly-frontend/src/main/js/package-lock.json +++ b/apps/dolly-frontend/src/main/js/package-lock.json @@ -4430,9 +4430,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001578", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001578.tgz", - "integrity": "sha512-J/jkFgsQ3NEl4w2lCoM9ZPxrD+FoBNJ7uJUpGVjIg/j0OwJosWM36EPDv+Yyi0V4twBk9pPmlFS+PLykgEvUmg==", + "version": "1.0.30001579", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz", + "integrity": "sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA==", "funding": [ { "type": "opencollective", @@ -5416,9 +5416,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.635", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.635.tgz", - "integrity": "sha512-iu/2D0zolKU3iDGXXxdOzNf72Jnokn+K1IN6Kk4iV6l1Tr2g/qy+mvmtfAiBwZe5S3aB5r92vp+zSZ69scYRrg==" + "version": "1.4.637", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.637.tgz", + "integrity": "sha512-G7j3UCOukFtxVO1vWrPQUoDk3kL70mtvjc/DC/k2o7lE0wAdq+Vwp1ipagOow+BH0uVztFysLWbkM/RTIrbK3w==" }, "node_modules/emoji-regex": { "version": "9.2.2", @@ -7781,9 +7781,9 @@ } }, "node_modules/joi": { - "version": "17.11.1", - "resolved": "https://registry.npmjs.org/joi/-/joi-17.11.1.tgz", - "integrity": "sha512-671acnrx+w96PCcQOzvm0VYQVwNL2PVgZmDRaFuSsx8sIUmGzYElPw5lU8F3Cr0jOuPs1oM56p7W2a1cdDOwcw==", + "version": "17.12.0", + "resolved": "https://registry.npmjs.org/joi/-/joi-17.12.0.tgz", + "integrity": "sha512-HSLsmSmXz+PV9PYoi3p7cgIbj06WnEBNT28n+bbBNcPZXZFqCzzvGqpTBPujx/Z0nh1+KNQPDrNgdmQ8dq0qYw==", "dev": true, "dependencies": { "@hapi/hoek": "^9.3.0", @@ -10591,9 +10591,9 @@ "dev": true }, "node_modules/sass": { - "version": "1.69.7", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.7.tgz", - "integrity": "sha512-rzj2soDeZ8wtE2egyLXgOOHQvaC2iosZrkF6v3EUG+tBwEvhqUCzm0VP3k9gHF9LXbSrRhT5SksoI56Iw8NPnQ==", + "version": "1.70.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.70.0.tgz", + "integrity": "sha512-uUxNQ3zAHeAx5nRFskBnrWzDUJrrvpCPD5FNAoRvTi0WwremlheES3tg+56PaVtCs5QDRX5CBLxxKMDJMEa1WQ==", "dev": true, "dependencies": { "chokidar": ">=3.0.0 <4.0.0", @@ -11392,9 +11392,9 @@ "optional": true }, "node_modules/terser": { - "version": "5.26.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.26.0.tgz", - "integrity": "sha512-dytTGoE2oHgbNV9nTzgBEPaqAWvcJNl66VZ0BkJqlvp71IjO8CxdBx/ykCNb47cLnCmCvRZ6ZR0tLkqvZCdVBQ==", + "version": "5.27.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.27.0.tgz", + "integrity": "sha512-bi1HRwVRskAjheeYl291n3JC4GgO/Ty4z1nVs5AAsmonJulGxpSektecnNedrwK9C7vpvVtcX3cw00VSLt7U2A==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/partials/EraseFillButtons.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/partials/EraseFillButtons.tsx index 28072e152b5..4e1b0034e3e 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/partials/EraseFillButtons.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/partials/EraseFillButtons.tsx @@ -7,14 +7,20 @@ export const EraseFillButtons = ({ formMethods, path, initialErase, initialFill
diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/brregstub/form/partials/orgnrToggle.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/brregstub/form/partials/orgnrToggle.tsx index ae6ba387119..5250a3d27b3 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/brregstub/form/partials/orgnrToggle.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/brregstub/form/partials/orgnrToggle.tsx @@ -8,6 +8,7 @@ import { EgneOrganisasjoner } from '@/components/fagsystem/brregstub/form/partia import { useDollyEnvironments } from '@/utils/hooks/useEnvironments' import { OrganisasjonLoader } from '@/components/organisasjonSelect/OrganisasjonLoader' import { UseFormReturn } from 'react-hook-form/dist/types' +import { ORGANISASJONSTYPE_TOGGLE } from '@/components/fagsystem/inntektstub/form/partials/orgnummerToggle' interface OrgnrToggleProps { path: string @@ -22,10 +23,13 @@ export const OrgnrToggle = ({ setEnhetsinfo, warningMessage, }: OrgnrToggleProps) => { - const [inputType, setInputType] = useState(inputValg.fraFellesListe) + const [inputType, setInputType] = useState( + sessionStorage.getItem(ORGANISASJONSTYPE_TOGGLE) || inputValg.fraFellesListe, + ) const { dollyEnvironments: aktiveMiljoer } = useDollyEnvironments() const handleToggleChange = (value: string) => { + sessionStorage.setItem(ORGANISASJONSTYPE_TOGGLE, value) setInputType(value) clearEnhetsinfo() } @@ -43,6 +47,7 @@ export const OrgnrToggle = ({ } oldValues['orgNr'] = null formMethods.setValue(path, oldValues) + formMethods.trigger(path) } const handleChange = (event: React.ChangeEvent) => { diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektsmelding/form/partials/orgnrToogle.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektsmelding/form/partials/orgnrToogle.tsx index 3aac46a60f9..17564ee0216 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektsmelding/form/partials/orgnrToogle.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektsmelding/form/partials/orgnrToogle.tsx @@ -7,6 +7,7 @@ import { } from '@/components/organisasjonSelect/OrganisasjonToogleGruppe' import { EgneOrganisasjoner } from '@/components/fagsystem/brregstub/form/partials/EgneOrganisasjoner' import { UseFormReturn } from 'react-hook-form/dist/types' +import { ORGANISASJONSTYPE_TOGGLE } from '@/components/fagsystem/inntektstub/form/partials/orgnummerToggle' interface OrgnrToggleProps { path: string @@ -14,9 +15,12 @@ interface OrgnrToggleProps { } export const OrgnrToggle = ({ path, formMethods }: OrgnrToggleProps) => { - const [inputType, setInputType] = useState(inputValg.fraFellesListe) + const [inputType, setInputType] = useState( + sessionStorage.getItem(ORGANISASJONSTYPE_TOGGLE) || inputValg.fraFellesListe, + ) const handleToggleChange = (value: string) => { + sessionStorage.setItem(ORGANISASJONSTYPE_TOGGLE, value) setInputType(value) formMethods.setValue(path, '') } diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektstub/form/partials/inntektsinformasjonLister/inntektForm.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektstub/form/partials/inntektsinformasjonLister/inntektForm.tsx index 9309878315a..a880b64af98 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektstub/form/partials/inntektsinformasjonLister/inntektForm.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektstub/form/partials/inntektsinformasjonLister/inntektForm.tsx @@ -7,7 +7,7 @@ import { useBoolean } from 'react-use' import { ToggleGroup } from '@navikt/ds-react' import { UseFormReturn } from 'react-hook-form/dist/types' -const INNTEKTSTYPE_TOGGLE = 'INNTEKTSTYPE_TOGGLE' +const INNTEKTSTYPE_FORENKLET_TOGGLE = 'INNTEKTSTYPE_FORENKLET_TOGGLE' export enum FormType { STANDARD = 'standard', @@ -58,7 +58,7 @@ const simpleValues = { export const InntektForm = ({ formMethods, inntektsinformasjonPath }: data) => { const [formSimple, setFormSimple] = useBoolean( - sessionStorage.getItem(INNTEKTSTYPE_TOGGLE) === FormType.FORENKLET, + sessionStorage.getItem(INNTEKTSTYPE_FORENKLET_TOGGLE) === FormType.FORENKLET, ) useEffect(() => { @@ -67,7 +67,7 @@ export const InntektForm = ({ formMethods, inntektsinformasjonPath }: data) => { const changeFormType = (type: FormType) => { const eventValueSimple = type === FormType.FORENKLET - sessionStorage.setItem(INNTEKTSTYPE_TOGGLE, type) + sessionStorage.setItem(INNTEKTSTYPE_FORENKLET_TOGGLE, type) setFormSimple(eventValueSimple) const restValues = eventValueSimple && { ...simpleValues } @@ -90,7 +90,7 @@ export const InntektForm = ({ formMethods, inntektsinformasjonPath }: data) => { <>
changeFormType(value)} size={'small'} style={{ backgroundColor: '#ffffff' }} diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektstub/form/partials/orgnummerToggle.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektstub/form/partials/orgnummerToggle.tsx index c4917844d9c..09d673c01a5 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektstub/form/partials/orgnummerToggle.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektstub/form/partials/orgnummerToggle.tsx @@ -28,12 +28,10 @@ export const OrgnummerToggle = ({ formMethods, opplysningspliktigPath, path }: P const [inputType, setInputType] = useState( sessionStorage.getItem(ORGANISASJONSTYPE_TOGGLE) || inputValg.fraFellesListe, ) - const [error, setError] = useState(null) const [success, setSuccess] = useBoolean(false) const [loading, setLoading] = useBoolean(false) const [environment, setEnvironment] = useState(null) const [orgnummer, setOrgnummer] = useState(formMethods.watch(path) || null) - console.log('path: ', path) //TODO - SLETT MEG const { organisasjon } = useFasteDataOrganisasjon(orgnummer) @@ -47,22 +45,21 @@ export const OrgnummerToggle = ({ formMethods, opplysningspliktigPath, path }: P const handleChange = (value: { juridiskEnhet: string; orgnr: string }) => { opplysningspliktigPath && formMethods.setValue(`${opplysningspliktigPath}`, value.juridiskEnhet) formMethods.trigger(opplysningspliktigPath) - formMethods.setValue(`${path}`, value.orgnr) + formMethods.setValue(path, value.orgnr) } - //TODO: Fikse henting fra testnav-org-service const handleManualOrgChange = (org: string, miljo: string) => { if (!org || !miljo) { return } - setError(null) + formMethods.clearErrors(path) setLoading(true) setSuccess(false) OrgserviceApi.getOrganisasjonInfo(org, miljo) .then((response: { data: { enhetType: string; juridiskEnhet: any; orgnummer: any } }) => { setLoading(false) if (!validEnhetstyper.includes(response.data.enhetType)) { - setError('Organisasjonen må være av type BEDR eller AAFY') + formMethods.setError(path, { message: 'Organisasjonen må være av type BEDR eller AAFY' }) return } if (!response.data.juridiskEnhet) { @@ -70,7 +67,7 @@ export const OrgnummerToggle = ({ formMethods, opplysningspliktigPath, path }: P opplysningspliktigPath && formMethods.setValue(`${opplysningspliktigPath}`, organisasjon.overenhet) } else { - setError('Organisasjonen mangler juridisk enhet') + formMethods.setError(path, { message: 'Organisasjonen mangler juridisk enhet' }) return } } @@ -82,7 +79,7 @@ export const OrgnummerToggle = ({ formMethods, opplysningspliktigPath, path }: P }) .catch(() => { setLoading(false) - setError('Fant ikke organisasjonen i ' + miljo) + formMethods.setError(path, { message: 'Fant ikke organisasjonen i ' + miljo }) }) } @@ -110,18 +107,14 @@ export const OrgnummerToggle = ({ formMethods, opplysningspliktigPath, path }: P path={path} environment={environment} miljoeOptions={aktiveMiljoer} - error={error} loading={loading} success={success} onTextBlur={(event) => { - console.log('event: ', event) //TODO - SLETT MEG const org = event.target.value setOrgnummer(org) handleManualOrgChange(org, environment) }} onMiljoeChange={(event) => { - console.log('orgnummer: ', orgnummer) //TODO - SLETT MEG - console.log('event2: ', event) //TODO - SLETT MEG setEnvironment(event.value) handleManualOrgChange(orgnummer, event.value) }} diff --git a/apps/dolly-frontend/src/main/js/src/components/inntektStub/validerInntekt/index.tsx b/apps/dolly-frontend/src/main/js/src/components/inntektStub/validerInntekt/index.tsx index f2463f1fc2b..c35fc614297 100644 --- a/apps/dolly-frontend/src/main/js/src/components/inntektStub/validerInntekt/index.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/inntektStub/validerInntekt/index.tsx @@ -31,7 +31,7 @@ const InntektStub = ({ inntektPath }) => { } = inntektValues useEffect(() => { - if (inntektstype !== '') { + if (!_.isEmpty(inntektstype)) { InntektstubService.validate(_.omitBy(inntektValues, (value) => value === '' || !value)).then( (response) => { setFields(response) diff --git a/apps/dolly-frontend/src/main/js/src/components/organisasjonSelect/OrganisasjonMedMiljoeSelect.tsx b/apps/dolly-frontend/src/main/js/src/components/organisasjonSelect/OrganisasjonMedMiljoeSelect.tsx index deee3063668..630ecd82df0 100644 --- a/apps/dolly-frontend/src/main/js/src/components/organisasjonSelect/OrganisasjonMedMiljoeSelect.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/organisasjonSelect/OrganisasjonMedMiljoeSelect.tsx @@ -8,7 +8,6 @@ interface OrgProps { path: string environment: string miljoeOptions: string[] - error: string success: boolean loading?: boolean onTextBlur: (event: React.ChangeEvent) => void @@ -30,10 +29,12 @@ export const OrganisasjonMedMiljoeSelect = ({ value: value.id, label: value.label, })) + const parentPath = path.substring(0, path.lastIndexOf('.')) return (
{ +export const Label = ({ name, fieldName, label, info = null, containerClass = null, children }) => { const { getFieldState, formState: { touchedFields, dirtyFields }, } = useFormContext() || useForm() - const { error } = getFieldState(name) - const isTouched = _.has(touchedFields, name) - const isDirtied = _.has(dirtyFields, name) + const isTouched = _.has(touchedFields, name) || _.has(touchedFields, fieldName) + const error = getFieldState(fieldName)?.error || getFieldState(name)?.error const errorContext: ShowErrorContextType = useContext(ShowErrorContext) const feilmelding = error?.message const wrapClass = cn('skjemaelement', containerClass, { @@ -47,7 +46,7 @@ export const Label = ({ name, label, info = null, containerClass = null, childre )} {children} - {!_.isEmpty(feilmelding) && (errorContext?.showError || isTouched || isDirtied) && ( + {!_.isEmpty(feilmelding) && (errorContext?.showError || isTouched) && (
{feilmelding}
diff --git a/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/select/Select.tsx b/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/select/Select.tsx index a0e8829df61..d3095fee0a0 100644 --- a/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/select/Select.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/select/Select.tsx @@ -161,6 +161,7 @@ const P_FormikSelect = ({ feil, ...props }: SelectProps) => { } field.onChange(SyntEvent(field.name, value)) if (props.afterChange) props.afterChange(selected) + formMethods.trigger(props.name) } const handleBlur = () => field?.onBlur?.(SyntEvent(field.name)) @@ -168,7 +169,6 @@ const P_FormikSelect = ({ feil, ...props }: SelectProps) => { return (