|
| 1 | +/* eslint-disable @typescript-eslint/no-explicit-any */ |
| 2 | +import { Grid, TableCell } from '@mui/material'; |
| 3 | +import { ErrorBoundary } from '../ErrorBoundary/ErrorBoundary.js'; |
| 4 | +import { ColView } from '../Helpers/ResponsiveColumns/responsive-coulmns.tsx/index.js'; |
| 5 | +import ResponsiveDataTable from '../ResponsiveDataTable.js'; |
| 6 | +import UsersTable from '../UsersTable/UsersTable.js'; |
| 7 | + |
| 8 | +interface TeamTableProps { |
| 9 | + teams: any; |
| 10 | + tableOptions: object; |
| 11 | + columnVisibility: Record<string, boolean>; |
| 12 | + colViews: ColView[]; |
| 13 | + tableCols: any[]; |
| 14 | + columns: any[]; |
| 15 | + updateCols: (cols: any) => void; |
| 16 | + isRemoveFromTeamAllowed: boolean; |
| 17 | + org_id: string; |
| 18 | + useGetUsersForOrgQuery: any; |
| 19 | + useNotificationHandlers: any; |
| 20 | + useRemoveUserFromTeamMutation: any; |
| 21 | +} |
| 22 | + |
| 23 | +const TeamTable: React.FC<TeamTableProps> = ({ |
| 24 | + teams, |
| 25 | + tableOptions, |
| 26 | + columnVisibility, |
| 27 | + colViews, |
| 28 | + tableCols, |
| 29 | + columns, |
| 30 | + updateCols, |
| 31 | + isRemoveFromTeamAllowed, |
| 32 | + org_id, |
| 33 | + useGetUsersForOrgQuery, |
| 34 | + useNotificationHandlers, |
| 35 | + useRemoveUserFromTeamMutation |
| 36 | +}) => { |
| 37 | + return ( |
| 38 | + <ErrorBoundary> |
| 39 | + <ResponsiveDataTable |
| 40 | + columns={columns} |
| 41 | + data={teams} |
| 42 | + options={{ |
| 43 | + ...tableOptions, |
| 44 | + renderExpandableRow: (_: any, rowMeta: any) => { |
| 45 | + const teamID = teams[rowMeta.dataIndex].id; |
| 46 | + return ( |
| 47 | + <TableCell |
| 48 | + colSpan={6} |
| 49 | + sx={{ |
| 50 | + padding: '0.5rem', |
| 51 | + backgroundColor: 'rgba(0, 0, 0, 0.05)' |
| 52 | + }} |
| 53 | + > |
| 54 | + <Grid |
| 55 | + container |
| 56 | + xs={12} |
| 57 | + spacing={1} |
| 58 | + sx={{ |
| 59 | + margin: 'auto', |
| 60 | + backgroundColor: '#f3f1f1', |
| 61 | + paddingLeft: '0.5rem', |
| 62 | + borderRadius: '0.25rem', |
| 63 | + width: 'inherit' |
| 64 | + }} |
| 65 | + > |
| 66 | + <UsersTable |
| 67 | + teamID={teamID} |
| 68 | + isRemoveFromTeamAllowed={isRemoveFromTeamAllowed} |
| 69 | + org_id={org_id} |
| 70 | + useGetUsersForOrgQuery={useGetUsersForOrgQuery} |
| 71 | + useNotificationHandlers={useNotificationHandlers} |
| 72 | + useRemoveUserFromTeamMutation={useRemoveUserFromTeamMutation} |
| 73 | + /> |
| 74 | + </Grid> |
| 75 | + </TableCell> |
| 76 | + ); |
| 77 | + } |
| 78 | + }} |
| 79 | + colViews={colViews} |
| 80 | + tableCols={tableCols} |
| 81 | + updateCols={updateCols} |
| 82 | + columnVisibility={columnVisibility} |
| 83 | + /> |
| 84 | + </ErrorBoundary> |
| 85 | + ); |
| 86 | +}; |
| 87 | + |
| 88 | +export default TeamTable; |
0 commit comments