@@ -11,9 +11,9 @@ import SearchResultLink from './searchResultLink'
11
11
import { Tabs } from '@navikt/ds-react'
12
12
import React , { useContext , useEffect , useState } from 'react'
13
13
import { SearchParam } from '../../pages/search'
14
- import { useRouter } from 'next/router'
15
14
import { USER_INFO } from '../../lib/queries/userInfo/userInfo'
16
15
import { UserState } from '../../lib/context'
16
+ import { useSearchTeamKatalogen } from '../../lib/rest/teamkatalogen'
17
17
import { useGetProductAreas } from '../../lib/rest/productAreas'
18
18
19
19
const Results = ( { children } : { children : React . ReactNode } ) => (
@@ -82,18 +82,29 @@ const ResultList = ({
82
82
// eslint-disable-next-line react-hooks/exhaustive-deps
83
83
} , [ search ] )
84
84
const [ deleteStoryQuery ] = useDeleteStoryMutation ( )
85
- const userInfo = useContext ( UserState )
85
+ const userInfo = useContext ( UserState )
86
+ const { searchResult : teamkatalogen } = useSearchTeamKatalogen ( )
87
+ const { productAreas } = useGetProductAreas ( )
86
88
const deleteStory = ( id : string ) => deleteStoryQuery ( {
87
- variables :{
89
+ variables : {
88
90
id : id
89
91
} ,
90
- refetchQueries :[
92
+ refetchQueries : [
91
93
{
92
94
query : USER_INFO ,
93
95
}
94
96
]
95
97
} )
96
98
99
+ const getTeamKatalogenInfo = ( item : any ) => {
100
+ const tk = teamkatalogen ?. find ( ( it ) => it . url == item ?. teamkatalogenURL )
101
+ const po = productAreas ?. find ( ( it ) => it . id == tk ?. productAreaID )
102
+ return {
103
+ productArea : po ?. name ,
104
+ teamkatalogenTeam : tk ?. name || item . group ?. group
105
+ }
106
+ }
107
+
97
108
if ( search && ! ! searchParam ) {
98
109
const { data, loading, error } = search
99
110
@@ -128,25 +139,25 @@ const ResultList = ({
128
139
</ Tabs . List >
129
140
< Tabs . Panel className = "flex flex-col pt-4 gap-4" value = "story" >
130
141
{ datastories . map (
131
- ( it , idx ) =>
142
+ ( it , idx ) =>
132
143
(
133
- it . result . __typename === 'Story' && (
134
- < SearchResultLink
135
- key = { idx }
136
- name = { it . result . name }
137
- type = { 'story' }
138
- keywords = { it . result . keywords }
139
- description = { it . excerpt }
140
- link = { `/story/${ it . result . id } ` }
141
- group = { {
142
- group : it . result . groupName ,
143
- teamkatalogenURL : it . result . teamkatalogenURL ,
144
- } }
145
- //TODO: fix teamkatalogen
146
- />
147
- )
144
+ it . result . __typename === 'Story' && (
145
+ < SearchResultLink
146
+ key = { idx }
147
+ name = { it . result . name }
148
+ type = { 'story' }
149
+ keywords = { it . result . keywords }
150
+ description = { it . excerpt }
151
+ link = { `/story/${ it . result . id } ` }
152
+ group = { {
153
+ group : it . result . groupName ,
154
+ teamkatalogenURL : it . result . teamkatalogenURL ,
155
+ } }
156
+ { ... getTeamKatalogenInfo ( it . result ) }
157
+ />
158
+ )
148
159
)
149
-
160
+
150
161
) }
151
162
</ Tabs . Panel >
152
163
< Tabs . Panel className = "flex flex-col gap-4" value = "dataproduct" >
@@ -161,7 +172,7 @@ const ResultList = ({
161
172
description = { d . result . description }
162
173
link = { `/dataproduct/${ d . result . id } /${ d . result . slug } ` }
163
174
datasets = { d . result . datasets }
164
- //TODO: fix teamkatalogen
175
+ { ... getTeamKatalogenInfo ( d . result ) }
165
176
/>
166
177
)
167
178
) }
@@ -181,7 +192,7 @@ const ResultList = ({
181
192
name = { d . name }
182
193
keywords = { d . keywords }
183
194
link = { `/dataproduct/${ d . id } /${ d . slug } ` }
184
- //TODO: fix teamkatalogen
195
+ { ... getTeamKatalogenInfo ( d ) }
185
196
/>
186
197
) ) }
187
198
</ Results >
@@ -203,11 +214,11 @@ const ResultList = ({
203
214
name = { s . name }
204
215
resourceType = { "datafortelling" }
205
216
link = { `/story/${ s . id } ` }
206
- //TODO: fix teamkatalogen
207
- keywords = { s . keywords }
208
- editable = { true }
209
- description = { s . description }
210
- deleteResource = { deleteStory }
217
+ { ... getTeamKatalogenInfo ( s ) }
218
+ keywords = { s . keywords }
219
+ editable = { true }
220
+ description = { s . description }
221
+ deleteResource = { deleteStory }
211
222
/>
212
223
) ) }
213
224
</ Results >
@@ -230,10 +241,10 @@ const ResultList = ({
230
241
id = { p . id }
231
242
name = { p . name }
232
243
link = { p . link }
233
- //TODO: fix teamkatalogen
234
- description = { p . description }
244
+ { ... getTeamKatalogenInfo ( p ) }
245
+ description = { p . description }
235
246
innsiktsproduktType = { p . type }
236
- editable = { ! ! userInfo ?. googleGroups ?. find ( it => it . email == p . group ) }
247
+ editable = { ! ! userInfo ?. googleGroups ?. find ( it => it . email == p . group ) }
237
248
/>
238
249
) ) }
239
250
</ Results >
0 commit comments