File tree Expand file tree Collapse file tree 3 files changed +24
-7
lines changed Expand file tree Collapse file tree 3 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -16,13 +16,12 @@ interface TeamTableProps {
16
16
columns : MUIDataTableColumn [ ] ;
17
17
updateCols : ( cols : any ) => void ;
18
18
isRemoveFromTeamAllowed : boolean ;
19
- isEditUserAllowed : any ;
20
- handleEditUser : any ;
19
+ isEditUserAllowed ? : any ;
20
+ handleEditUser ? : any ;
21
21
org_id : string ;
22
22
useGetUsersForOrgQuery : any ;
23
23
useNotificationHandlers : any ;
24
24
useRemoveUserFromTeamMutation : any ;
25
- availableRoles ?: string [ ] ;
26
25
}
27
26
const StyledGrid = styled ( Grid2 ) ( ( { theme } ) => ( {
28
27
display : 'grid' ,
Original file line number Diff line number Diff line change @@ -115,9 +115,29 @@ const UsersTable: React.FC<UsersTableProps> = ({
115
115
orgId : org_id
116
116
} ) ;
117
117
118
+ //->calling without teamId filter to get organization roles
119
+ const { data : fullUserData } = useGetUsersForOrgQuery ( {
120
+ page : 0 ,
121
+ pagesize : pageSize ,
122
+ search : search ,
123
+ order : sortOrder ,
124
+ orgId : org_id
125
+ } ) ;
126
+
118
127
const [ removeUserFromTeam ] = useRemoveUserFromTeamMutation ( ) ;
119
128
120
129
const users = userData ?. data || [ ] ;
130
+ const fullUsers = fullUserData ?. data || [ ] ;
131
+
132
+ const enrichedUsers = users . map ( ( teamUser : any ) => {
133
+ const fullUser = fullUsers . find ( ( fu : any ) => fu . user_id === teamUser . user_id ) ;
134
+ const teamRoles = teamUser . role_names || [ ] ;
135
+ const organizationRoles = fullUser ?. organization_with_user_roles ?. role_names || [ ] ;
136
+ return {
137
+ ...teamUser ,
138
+ role_names : [ ...teamRoles , ...organizationRoles ]
139
+ } ;
140
+ } ) ;
121
141
const count = userData ?. total_count || 0 ;
122
142
123
143
const handleRemoveFromTeam = ( data : any [ ] ) => async ( ) => {
@@ -407,7 +427,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
407
427
fullWidth : true
408
428
} ,
409
429
customBodyRender : ( _ : string , tableMeta : MUIDataTableMeta ) => {
410
- const rowData = users [ tableMeta . rowIndex ] ;
430
+ const rowData = enrichedUsers [ tableMeta . rowIndex ] ;
411
431
return parseDeletionTimestamp ( rowData ) ;
412
432
}
413
433
}
@@ -462,7 +482,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
462
482
< div style = { { margin : 'auto' , width : '100%' } } >
463
483
< ResponsiveDataTable
464
484
columns = { columns }
465
- data = { users }
485
+ data = { enrichedUsers }
466
486
options = { options }
467
487
colViews = { colViews }
468
488
tableCols = { tableCols }
Original file line number Diff line number Diff line change @@ -147,8 +147,6 @@ const TeamsTable: React.FC<TeamsTableProps> = ({
147
147
useGetUsersForOrgQuery = { useGetUsersForOrgQuery }
148
148
useNotificationHandlers = { useNotificationHandlers }
149
149
useRemoveUserFromTeamMutation = { useRemoveUserFromTeamMutation }
150
- isEditUserAllowed = { false }
151
- handleEditUser = { ( ) => { } }
152
150
/>
153
151
154
152
< AssignmentModal
You can’t perform that action at this time.
0 commit comments