@@ -19,7 +19,7 @@ import { QueryErrorWrapper } from "@common/components/query-error-boundary/Query
19
19
import { SOKNAD_LABELS } from "@common/constants/soknadFraLabels" ;
20
20
import text from "@common/constants/texts" ;
21
21
import { useBehandlingProvider } from "@common/context/BehandlingContext" ;
22
- import { getFirstDayOfMonthAfterEighteenYears } from "@common/helpers/boforholdFormHelpers" ;
22
+ import { getFirstDayOfMonthAfterEighteenYears , isOver18YearsOld } from "@common/helpers/boforholdFormHelpers" ;
23
23
import {
24
24
aarsakToVirkningstidspunktMapper ,
25
25
getFomAndTomForMonthPicker ,
@@ -35,7 +35,6 @@ import React, { useEffect, useMemo, useState } from "react";
35
35
import { FormProvider , useForm , useFormContext } from "react-hook-form" ;
36
36
37
37
import { CustomTextareaEditor } from "../../../../common/components/CustomEditor" ;
38
- import useFeatureToogle from "../../../../common/hooks/useFeatureToggle" ;
39
38
import { STEPS } from "../../../constants/steps" ;
40
39
import { BarnebidragStepper } from "../../../enum/BarnebidragStepper" ;
41
40
import { useOnSaveVirkningstidspunkt } from "../../../hooks/useOnSaveVirkningstidspunkt" ;
@@ -133,8 +132,11 @@ const createPayload = (values: VirkningstidspunktFormValues): OppdatereVirknings
133
132
} ;
134
133
} ;
135
134
136
- const getOpphørOptions = ( opphør : OpphorsdetaljerRolleDto , stønadstype : Stonadstype ) => {
137
- if ( stønadstype === Stonadstype . BIDRAG18AAR ) {
135
+ const getOpphørOptions = ( opphør : OpphorsdetaljerRolleDto , stønadstype : Stonadstype , fødselsdato : string ) => {
136
+ if (
137
+ stønadstype === Stonadstype . BIDRAG18AAR ||
138
+ ( stønadstype === Stonadstype . BIDRAG && isOver18YearsOld ( fødselsdato ) )
139
+ ) {
138
140
if ( opphør ?. eksisterendeOpphør ) {
139
141
return [ OpphørsVarighet . VELG_OPPHØRSDATO , OpphørsVarighet . FORTSETTE_OPPHØR ] ;
140
142
} else {
@@ -213,8 +215,15 @@ const Main = ({ initialValues, previousValues, setPreviousValues, showChangedVir
213
215
onSelect = { onAarsakSelect }
214
216
className = "w-max"
215
217
>
216
- { erÅrsakAvslagIkkeValgt && < option value = "" > { text . select . årsakAvslagPlaceholder } </ option > }
217
- { ! erTypeOpphør && (
218
+ { lesemodus && (
219
+ < option value = { getValues ( "årsakAvslag" ) } >
220
+ { hentVisningsnavnVedtakstype ( getValues ( "årsakAvslag" ) , behandling . vedtakstype ) }
221
+ </ option >
222
+ ) }
223
+ { ! lesemodus && erÅrsakAvslagIkkeValgt && (
224
+ < option value = "" > { text . select . årsakAvslagPlaceholder } </ option >
225
+ ) }
226
+ { ! lesemodus && ! erTypeOpphør && (
218
227
< optgroup label = { text . label . årsak } >
219
228
{ virkningsårsaker
220
229
. filter ( ( value ) => {
@@ -229,7 +238,7 @@ const Main = ({ initialValues, previousValues, setPreviousValues, showChangedVir
229
238
</ optgroup >
230
239
) }
231
240
232
- { er18ÅrsBidrag ? (
241
+ { ! lesemodus && er18ÅrsBidrag ? (
233
242
< optgroup label = { erTypeOpphørOrLøpendeBidrag ? text . label . opphør : text . label . avslag } >
234
243
{ ( erTypeOpphørOrLøpendeBidrag ? avslagsListe18ÅrOpphør : avslagsListe18År ) . map ( ( value ) => (
235
244
< option key = { value } value = { value } >
@@ -290,7 +299,6 @@ const Main = ({ initialValues, previousValues, setPreviousValues, showChangedVir
290
299
} ;
291
300
292
301
const Opphør = ( { initialValues, previousValues, setPreviousValues } ) => {
293
- const { isOpphørsdatoEnabled } = useFeatureToogle ( ) ;
294
302
const behandling = useGetBehandlingV2 ( ) ;
295
303
//TODO: Dette må tilpasses per barn i V3 av bidrag
296
304
const baRolle = behandling . roller . find ( ( rolle ) => rolle . rolletype === Rolletype . BA ) ;
@@ -356,7 +364,6 @@ const Opphør = ({ initialValues, previousValues, setPreviousValues }) => {
356
364
} ;
357
365
358
366
if ( behandling . virkningstidspunkt . avslag != null ) return null ;
359
- if ( ! isOpphørsdatoEnabled ) return null ;
360
367
return (
361
368
< >
362
369
{ opphør ?. eksisterendeOpphør && (
@@ -377,7 +384,7 @@ const Opphør = ({ initialValues, previousValues, setPreviousValues }) => {
377
384
className = "w-max"
378
385
onSelect = { ( value ) => onSelectVarighet ( value ) }
379
386
>
380
- { getOpphørOptions ( opphør , behandling . stønadstype ) . map ( ( value ) => (
387
+ { getOpphørOptions ( opphør , behandling . stønadstype , baRolle . fødselsdato ) . map ( ( value ) => (
381
388
< option key = { value } value = { value } >
382
389
{ value }
383
390
</ option >
@@ -454,7 +461,7 @@ const VirkningstidspunktForm = () => {
454
461
error : ! ObjectUtils . isEmpty ( useFormMethods . formState . errors ) ,
455
462
} ,
456
463
} ) ) ;
457
- } , [ useFormMethods . formState . errors ] ) ;
464
+ } , [ JSON . stringify ( useFormMethods . formState . errors ) ] ) ;
458
465
459
466
useEffect ( ( ) => {
460
467
const subscription = useFormMethods . watch ( ( value , { name, type } ) => {
0 commit comments