@@ -2,14 +2,17 @@ import React, { useCallback, useEffect, useId, useState } from 'react';
2
2
import { Search } from '@navikt/ds-react' ;
3
3
import debounce from 'lodash.debounce' ;
4
4
import { translator } from 'translations' ;
5
+ import { AnalyticsEvents , logAmplitudeEvent } from 'utils/amplitude' ;
5
6
import { usePageContentProps } from 'store/pageContext' ;
7
+ import { getDecoratorParams } from 'utils/decorator-utils' ;
8
+ import { innholdsTypeMap } from 'types/content-props/_content-common' ;
6
9
import { useOverviewFilters } from 'store/hooks/useOverviewFilters' ;
7
10
import { windowScrollTo } from 'utils/scroll-to' ;
8
- import { AnalyticsEvents , logAmplitudeEvent } from 'utils/amplitude' ;
9
11
import {
10
12
OVERVIEW_FILTERS_TEXT_INPUT_EVENT ,
11
13
OverviewFiltersTextInputEventDetail ,
12
14
} from 'store/slices/overviewFilters' ;
15
+
13
16
import style from './OverviewTextFilter.module.scss' ;
14
17
15
18
type Props = {
@@ -23,9 +26,10 @@ const analyticsRedaction = (value: string) =>
23
26
24
27
export const OverviewTextFilter = ( { hideLabel } : Props ) => {
25
28
const { setTextFilter } = useOverviewFilters ( ) ;
26
- const { language } = usePageContentProps ( ) ;
29
+ const contentProps = usePageContentProps ( ) ;
30
+ const { context } = getDecoratorParams ( contentProps ) ;
31
+ const label = translator ( 'overview' , contentProps . language ) ( 'search' ) ;
27
32
const inputId = useId ( ) ;
28
-
29
33
const [ textInput , setTextInput ] = useState ( '' ) ;
30
34
31
35
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -44,6 +48,8 @@ export const OverviewTextFilter = ({ hideLabel }: Props) => {
44
48
kategori : 'fritekst' ,
45
49
filternavn : analyticsRedaction ( value ) ,
46
50
komponent : 'OverviewTextFilter' ,
51
+ målgruppe : context ,
52
+ innholdstype : innholdsTypeMap [ contentProps . type ] ,
47
53
} ) ;
48
54
} , 500 ) ,
49
55
[ setTextFilter ]
@@ -61,7 +67,6 @@ export const OverviewTextFilter = ({ hideLabel }: Props) => {
61
67
setTextInput ( value ) ;
62
68
}
63
69
} ;
64
-
65
70
window . addEventListener ( OVERVIEW_FILTERS_TEXT_INPUT_EVENT , handleInputFromEvent ) ;
66
71
return ( ) => {
67
72
window . removeEventListener ( OVERVIEW_FILTERS_TEXT_INPUT_EVENT , handleInputFromEvent ) ;
@@ -95,7 +100,7 @@ export const OverviewTextFilter = ({ hideLabel }: Props) => {
95
100
< Search
96
101
onChange = { handleUserInput }
97
102
value = { textInput }
98
- label = { translator ( 'overview' , language ) ( 'search' ) }
103
+ label = { label }
99
104
hideLabel = { hideLabel }
100
105
variant = { 'secondary' }
101
106
autoComplete = { 'off' }
0 commit comments