1
1
import * as R from 'remeda'
2
- import React , { ReactElement } from 'react'
3
- import { BodyShort , Heading } from '@navikt/ds-react'
2
+ import React , { ReactElement , Suspense } from 'react'
3
+ import { BodyShort , Detail , Heading , Skeleton } from '@navikt/ds-react'
4
4
// @ts -expect-error TODO, link panel is deprecated
5
5
import { LinkPanel , LinkPanelDescription , LinkPanelTitle } from '@navikt/ds-react/LinkPanel'
6
6
import { Metadata } from 'next'
@@ -22,6 +22,7 @@ import EditableFrequency from '../../../../components/edit/EditableFrequency'
22
22
import { PingDot } from '../../../../components/core/Dots'
23
23
import { createPermalink } from '../../../../utils/slack'
24
24
import { dayIndexToDay } from '../../../../utils/date'
25
+ import { getGroup } from '../../../../auth/ms-graph'
25
26
26
27
export const metadata : Metadata = {
27
28
title : 'Helsesjekk | Team' ,
@@ -100,6 +101,7 @@ async function Page({ params }: Props): Promise<ReactElement> {
100
101
/>
101
102
< EditableTime teamId = { team . id } hour = { team . postHour } day = { team . postDay } type = "ask" />
102
103
< EditableTime teamId = { team . id } hour = { team . revealHour } day = { team . revealDay } type = "reveal" />
104
+ < AssociatedGroup groupId = { team . assosiatedGroup } />
103
105
< Questions teamId = { team . id } questions = { questionsFromJsonb ( team . questions ) } />
104
106
</ div >
105
107
)
@@ -167,4 +169,53 @@ function Questions({ teamId, questions }: { teamId: string; questions: Question[
167
169
)
168
170
}
169
171
172
+ function AssociatedGroup ( { groupId } : { groupId : string | null } ) : ReactElement {
173
+ return (
174
+ < div className = "p-3 bg-bg-subtle rounded my-4" >
175
+ < div className = "flex gap-2 items-center justify-between" >
176
+ < Heading size = "small" > Assosiert gruppe</ Heading >
177
+ < Detail > ID: { groupId } </ Detail >
178
+ </ div >
179
+ { groupId == null ? (
180
+ < BodyShort > Ingen assosiert gruppe</ BodyShort >
181
+ ) : (
182
+ < >
183
+ < Suspense
184
+ fallback = {
185
+ < >
186
+ < Skeleton />
187
+ < Skeleton />
188
+ </ >
189
+ }
190
+ >
191
+ < AssociatedGroupName groupId = { groupId } />
192
+ </ Suspense >
193
+ </ >
194
+ ) }
195
+ < div className = "mt-4" >
196
+ < BodyShort size = "small" >
197
+ For å endre gruppen så er det beskrevet på < Link href = "/kom-i-gang#koble-til" > Kom i gang</ Link > { ' ' }
198
+ siden
199
+ </ BodyShort >
200
+ </ div >
201
+ </ div >
202
+ )
203
+ }
204
+
205
+ async function AssociatedGroupName ( { groupId } : { groupId : string } ) : Promise < ReactElement > {
206
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
207
+ const group = await getGroup ( groupId )
208
+
209
+ if ( 'error' in group ) {
210
+ return < BodyShort > { group . error } </ BodyShort >
211
+ }
212
+
213
+ return (
214
+ < >
215
+ < BodyShort > { group . displayName ?? 'Gruppe uten navn' } </ BodyShort >
216
+ { group . description && < BodyShort size = "small" > { group . description } </ BodyShort > }
217
+ </ >
218
+ )
219
+ }
220
+
170
221
export default Page
0 commit comments