1
1
import { Alert , Heading } from '@navikt/ds-react' ;
2
2
import React , { useCallback } from 'react' ;
3
3
import { FormattedMessage , IntlShape , injectIntl } from 'react-intl' ;
4
-
5
4
import { TextAreaFormik , TextFieldFormik } from '@fpsak-frontend/form' ;
6
5
import { VerticalSpacer } from '@fpsak-frontend/shared-components' ;
7
6
import { hasValidText , maxLength , minLength , required } from '@fpsak-frontend/utils' ;
@@ -11,17 +10,13 @@ import {
11
10
kanHaManueltFritekstbrev ,
12
11
} from '@fpsak-frontend/utils/src/formidlingUtils' ;
13
12
import { DokumentDataType } from '@k9-sak-web/types/src/dokumentdata' ;
14
- import { useContext } from 'react' ;
15
-
16
13
import InkluderKalenderCheckbox from './InkluderKalenderCheckbox' ;
17
-
18
14
import FritekstRedigering from './FritekstRedigering/FritekstRedigering' ;
19
- import styles from './vedtakForm.module.css' ;
20
-
21
- import FeatureTogglesContext from '@k9-sak-web/gui/featuretoggles/FeatureTogglesContext.js' ;
22
15
import { fieldnames } from '../konstanter' ;
23
16
import { CustomFormikProps } from './brev/CustomFormikProps' ;
24
17
18
+ import styles from './vedtakForm.module.css' ;
19
+
25
20
const maxLength200 = maxLength ( 200 ) ;
26
21
const maxLength100000 = maxLength ( 100000 ) ;
27
22
const minLength3 = minLength ( 3 ) ;
@@ -58,7 +53,6 @@ const FritekstBrevPanel = ({
58
53
setForhaandsvisningKlart,
59
54
} : OwnProps ) => {
60
55
const { formatMessage } = intl ;
61
- const featureToggles = useContext ( FeatureTogglesContext ) ;
62
56
const kanRedigereFritekstbrev = kanHaManueltFritekstbrev ( tilgjengeligeVedtaksbrev ) ;
63
57
64
58
// useCallback to avoid re-initializing FritekstRedigering editorjs on every re-render of this component
@@ -76,13 +70,15 @@ const FritekstBrevPanel = ({
76
70
< Heading className = { styles . brevHeading } size = "small" level = "2" >
77
71
< FormattedMessage id = "VedtakForm.Brev" />
78
72
</ Heading >
73
+
79
74
{ ! readOnly && harAutomatiskVedtaksbrev && (
80
75
< div className = { styles . brevAlertContainer } data-testid = "harAutomatiskVedtaksbrev" >
81
76
< Alert variant = "info" size = "small" >
82
77
< FormattedMessage id = "VedtakForm.AutomatiskBrev" />
83
78
</ Alert >
84
79
</ div >
85
80
) }
81
+
86
82
{ ! readOnly && ! harAutomatiskVedtaksbrev && (
87
83
< div className = { styles . brevAlertContainer } data-testid = "harIkkeAutomatiskVedtaksbrev" >
88
84
< Alert variant = "info" size = "small" >
@@ -91,27 +87,26 @@ const FritekstBrevPanel = ({
91
87
</ div >
92
88
) }
93
89
94
- { ! featureToggles . FRITEKST_REDIGERING ||
95
- ( ! kanRedigereFritekstbrev && (
96
- < div className = { readOnly ? '' : styles . brevFormContainer } >
97
- < TextFieldFormik
98
- name = "overskrift"
99
- label = { formatMessage ( { id : 'VedtakForm.Overskrift' } ) }
100
- validate = { [ required , minLength3 , maxLength200 , hasValidText ] }
101
- maxLength = { 200 }
90
+ { ! kanRedigereFritekstbrev && (
91
+ < div className = { readOnly ? '' : styles . brevFormContainer } >
92
+ < TextFieldFormik
93
+ name = "overskrift"
94
+ label = { formatMessage ( { id : 'VedtakForm.Overskrift' } ) }
95
+ validate = { [ required , minLength3 , maxLength200 , hasValidText ] }
96
+ maxLength = { 200 }
97
+ readOnly = { readOnly }
98
+ />
99
+ < div className = { readOnly ? styles [ 'textAreaContainer--readOnly' ] : styles . textAreaContainer } >
100
+ < TextAreaFormik
101
+ name = "brødtekst"
102
+ label = { formatMessage ( { id : 'VedtakForm.Innhold' } ) }
103
+ validate = { [ required , minLength3 , maxLength100000 , hasValidText ] }
104
+ maxLength = { 100000 }
102
105
readOnly = { readOnly }
103
106
/>
104
- < div className = { readOnly ? styles [ 'textAreaContainer--readOnly' ] : styles . textAreaContainer } >
105
- < TextAreaFormik
106
- name = "brødtekst"
107
- label = { formatMessage ( { id : 'VedtakForm.Innhold' } ) }
108
- validate = { [ required , minLength3 , maxLength100000 , hasValidText ] }
109
- maxLength = { 100000 }
110
- readOnly = { readOnly }
111
- />
112
- </ div >
113
107
</ div >
114
- ) ) }
108
+ </ div >
109
+ ) }
115
110
116
111
{ kanRedigereFritekstbrev && formikProps . values . skalBrukeOverstyrendeFritekstBrev && (
117
112
< div className = { readOnly ? 'readOnly' : styles . manueltBrevFormContainer } >
0 commit comments