1
- import { BodyShort , Detail , Link , Pagination , ReadMore , Select } from '@navikt/ds-react' ;
1
+ import { BodyShort , Checkbox , Detail , Link , Pagination , ReadMore , Select } from '@navikt/ds-react' ;
2
2
import { format } from 'date-fns' ;
3
3
import { nb } from 'date-fns/locale' ;
4
4
import { Dokument } from 'lib/types/types' ;
5
5
import styles from './Dokumentoversikt.module.css' ;
6
6
import { useEffect , useMemo , useState } from 'react' ;
7
- import { logAmplitudeEvent , logDokumentoversiktEvent } from 'lib/utils/amplitude' ;
7
+ import { logDokumentoversiktEvent } from 'lib/utils/amplitude' ;
8
8
import { useFeatureToggleIntl } from 'lib/hooks/useFeatureToggleIntl' ;
9
9
10
10
const getAvsender = ( type : string ) => {
@@ -29,14 +29,15 @@ export const Dokumentoversikt = ({ dokumenter }: { dokumenter: Dokument[] }) =>
29
29
const [ sortType , setSortType ] = useState ( 'datoAsc' ) ;
30
30
const [ pageNumber , setPageNumber ] = useState ( 1 ) ;
31
31
const [ searchFilter , setSearchFilter ] = useState ( '' ) ;
32
+ const [ visMeldekort , setVisMeldekort ] = useState ( true ) ;
32
33
33
34
const { formatMessage } = useFeatureToggleIntl ( ) ;
34
35
35
36
const filtrerteDokumenter = useMemo ( ( ) => {
36
37
return sorterteDokumenter . filter ( ( dokument ) => {
37
38
if ( searchFilter ) {
38
39
return (
39
- dokument . tittel . toLowerCase ( ) . includes ( searchFilter . toLowerCase ( ) ) ||
40
+ ! dokument . tittel . toLowerCase ( ) . includes ( searchFilter . toLowerCase ( ) ) ||
40
41
getAvsender ( dokument . type ) . toLowerCase ( ) . includes ( searchFilter . toLowerCase ( ) )
41
42
) ;
42
43
}
@@ -62,6 +63,14 @@ export const Dokumentoversikt = ({ dokumenter }: { dokumenter: Dokument[] }) =>
62
63
}
63
64
} , [ filtrerteDokumenter , pageNumber ] ) ;
64
65
66
+ useEffect ( ( ) => {
67
+ if ( visMeldekort ) {
68
+ setSearchFilter ( 'Meldekort for uke' ) ;
69
+ } else {
70
+ setSearchFilter ( '' ) ;
71
+ }
72
+ } , [ visMeldekort ] ) ;
73
+
65
74
const onSortChange = ( e : React . ChangeEvent < HTMLSelectElement > ) => {
66
75
const value = e . target . value ;
67
76
logDokumentoversiktEvent ( antallSider , `sorter etter ${ value } ` ) ;
@@ -83,10 +92,6 @@ export const Dokumentoversikt = ({ dokumenter }: { dokumenter: Dokument[] }) =>
83
92
84
93
return (
85
94
< div className = { styles . container } >
86
- < ReadMore header = { formatMessage ( 'dokumentoversikt.manglendeDokument.header' ) } >
87
- < BodyShort > { formatMessage ( 'dokumentoversikt.manglendeDokument.tekst' ) } </ BodyShort >
88
- { formatMessage ( 'dokumentoversikt.manglendeDokument.bulletsTekst' ) }
89
- </ ReadMore >
90
95
< div style = { { display : 'flex' , flexDirection : 'column' , gap : '0.75rem' } } >
91
96
< Select label = "Sorter etter" onChange = { onSortChange } >
92
97
< option value = "datoAsc" > Nyeste først</ option >
@@ -98,6 +103,13 @@ export const Dokumentoversikt = ({ dokumenter }: { dokumenter: Dokument[] }) =>
98
103
onClear={() => setSearchFilter('')}
99
104
hideLabel={false}
100
105
/>*/ }
106
+ < Checkbox
107
+ value = { visMeldekort }
108
+ checked = { ! visMeldekort }
109
+ onChange = { ( ) => setVisMeldekort ( ! visMeldekort ) }
110
+ >
111
+ Vis meldekort
112
+ </ Checkbox >
101
113
</ div >
102
114
< ul style = { { listStyle : 'none' , margin : '0' , padding : '0' } } >
103
115
{ sortedPaginatedDocuments . map ( ( document ) => {
0 commit comments