8
8
import { Box , Dialog , DialogActions , DialogContent , DialogTitle , Grid , Typography } from '@mui/material' ;
9
9
import { FormattedMessage } from 'react-intl' ;
10
10
import type { User } from 'oidc-client' ;
11
- import { useEffect , useState } from 'react' ;
11
+ import { Fragment , useEffect , useState } from 'react' ;
12
12
import { CancelButton } from '../inputs/reactHookForm/utils/CancelButton' ;
13
13
import { fetchUserDetails } from '../../services/userAdmin' ;
14
14
import { UserDetail } from '../../utils/types/types' ;
@@ -46,6 +46,9 @@ function UserInformationDialog({ openDialog, user, onClose }: UserInformationDia
46
46
}
47
47
} , [ openDialog , user ] ) ;
48
48
49
+ const rolesString = user ?. profile ?. profile ?? '' ;
50
+ const rolesList = rolesString ? rolesString . split ( '|' ) . map ( ( role ) => role . trim ( ) ) : [ ] ;
51
+
49
52
return (
50
53
< Dialog open = { openDialog && ! ! user && ! ! userDetails } onClose = { onClose } >
51
54
< DialogTitle fontWeight = "bold" sx = { styles . DialogTitle } >
@@ -60,15 +63,23 @@ function UserInformationDialog({ openDialog, user, onClose }: UserInformationDia
60
63
</ Typography >
61
64
</ Grid >
62
65
< Grid item xs = { 6 } >
63
- < Typography >
64
- < FormattedMessage
65
- id = {
66
- userDetails ?. isAdmin
67
- ? 'user-information-dialog/role-admin'
68
- : 'user-information-dialog/role-user'
69
- }
70
- />
71
- </ Typography >
66
+ { rolesList . length > 0 ? (
67
+ < Typography >
68
+ { rolesList . map ( ( role , index ) => (
69
+ < Fragment key = { role } >
70
+ { index > 0 && ' | ' }
71
+ < FormattedMessage
72
+ id = { `user-information-dialog/${ role } ` }
73
+ defaultMessage = { role }
74
+ />
75
+ </ Fragment >
76
+ ) ) }
77
+ </ Typography >
78
+ ) : (
79
+ < Typography >
80
+ < FormattedMessage id = "user-information-dialog/no-roles" />
81
+ </ Typography >
82
+ ) }
72
83
</ Grid >
73
84
74
85
< Grid item xs = { 6 } >
0 commit comments