diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/form/Form.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/form/Form.tsx index 581cc8c2d95..d684505a673 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/form/Form.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/form/Form.tsx @@ -23,9 +23,13 @@ export const YrkesskaderForm = () => { const formMethods = useFormContext() const handleChangeTidstype = (value, path) => { - formMethods.setValue(`${path}.tidstype`, value?.value) + formMethods.setValue(`${path}.tidstype`, value?.value || null) formMethods.setValue(`${path}.skadetidspunkt`, null) - formMethods.setValue(`${path}.perioder`, [initialYrkesskadePeriode]) + if (value?.value === 'periode') { + formMethods.setValue(`${path}.perioder`, [initialYrkesskadePeriode]) + } else { + formMethods.setValue(`${path}.perioder`, null) + } formMethods.trigger(path) } diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/form/validation.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/form/validation.tsx index d2a0f005a52..346f9196c40 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/form/validation.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/form/validation.tsx @@ -12,8 +12,19 @@ export const validation = { referanse: Yup.string().nullable(), ferdigstillSak: Yup.string().nullable(), tidstype: Yup.string().nullable(), - // skadetidspunkt: null, - // perioder: null, + skadetidspunkt: Yup.mixed().when('tidstype', { + is: (tidstype: string) => tidstype === 'tidspunkt', + then: () => requiredString, + otherwise: () => Yup.mixed().notRequired(), + }), + perioder: Yup.array() + .of( + Yup.object({ + fra: ifPresent('$fra', requiredString), + til: ifPresent('$til', requiredString), + }), + ) + .nullable(), }), ), ), diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/initialValues.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/initialValues.tsx index f4f818ef2b4..78bb217364c 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/initialValues.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/yrkesskader/initialValues.tsx @@ -4,12 +4,9 @@ export const initialYrkesskadePeriode = { } export const initialYrkesskade = { - // skadelidtIdentifikator: '', rolletype: 'arbeidstaker', - // innmelderIdentifikator: null, innmelderrolle: 'virksomhetsrepresentant', klassifisering: 'MANUELL', - // paaVegneAv: null, tidstype: null, skadetidspunkt: null, perioder: null,