File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,13 +16,12 @@ interface TeamTableProps {
1616 columns : MUIDataTableColumn [ ] ;
1717 updateCols : ( cols : any ) => void ;
1818 isRemoveFromTeamAllowed : boolean ;
19- isEditUserAllowed : any ;
20- handleEditUser : any ;
19+ isEditUserAllowed ? : any ;
20+ handleEditUser ? : any ;
2121 org_id : string ;
2222 useGetUsersForOrgQuery : any ;
2323 useNotificationHandlers : any ;
2424 useRemoveUserFromTeamMutation : any ;
25- availableRoles ?: string [ ] ;
2625}
2726const StyledGrid = styled ( Grid2 ) ( ( { theme } ) => ( {
2827 display : 'grid' ,
Original file line number Diff line number Diff line change @@ -115,9 +115,29 @@ const UsersTable: React.FC<UsersTableProps> = ({
115115 orgId : org_id
116116 } ) ;
117117
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+
118127 const [ removeUserFromTeam ] = useRemoveUserFromTeamMutation ( ) ;
119128
120129 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+ } ) ;
121141 const count = userData ?. total_count || 0 ;
122142
123143 const handleRemoveFromTeam = ( data : any [ ] ) => async ( ) => {
@@ -407,7 +427,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
407427 fullWidth : true
408428 } ,
409429 customBodyRender : ( _ : string , tableMeta : MUIDataTableMeta ) => {
410- const rowData = users [ tableMeta . rowIndex ] ;
430+ const rowData = enrichedUsers [ tableMeta . rowIndex ] ;
411431 return parseDeletionTimestamp ( rowData ) ;
412432 }
413433 }
@@ -462,7 +482,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
462482 < div style = { { margin : 'auto' , width : '100%' } } >
463483 < ResponsiveDataTable
464484 columns = { columns }
465- data = { users }
485+ data = { enrichedUsers }
466486 options = { options }
467487 colViews = { colViews }
468488 tableCols = { tableCols }
Original file line number Diff line number Diff line change @@ -147,8 +147,6 @@ const TeamsTable: React.FC<TeamsTableProps> = ({
147147 useGetUsersForOrgQuery = { useGetUsersForOrgQuery }
148148 useNotificationHandlers = { useNotificationHandlers }
149149 useRemoveUserFromTeamMutation = { useRemoveUserFromTeamMutation }
150- isEditUserAllowed = { false }
151- handleEditUser = { ( ) => { } }
152150 />
153151
154152 < AssignmentModal
You can’t perform that action at this time.
0 commit comments