import Link from 'next/link'; import { Button, Flexbox, Icon, Icons, Modal, ModalTrigger, Table, TableBody, TableCell, TableColumn, TableHeader, TableRow, Text, } from 'react-basics'; import TeamDeleteForm from './TeamDeleteForm'; import useMessages from 'hooks/useMessages'; import useUser from 'hooks/useUser'; import { ROLES } from 'lib/constants'; export default function TeamsTable({ data = [], onDelete }) { const { formatMessage, labels } = useMessages(); const { user } = useUser(); const columns = [ { name: 'name', label: formatMessage(labels.name), style: { flex: 2 } }, { name: 'owner', label: formatMessage(labels.owner) }, { name: 'action', label: ' ' }, ]; return ( {(column, index) => { return ( {column.label} ); }} {(row, keys, rowIndex) => { const { id } = row; const owner = row.teamUser.find(({ role }) => role === ROLES.teamOwner); const showDelete = user.id === owner?.userId; const rowData = { ...row, owner: owner?.user?.username, action: ( {showDelete && ( {close => ( )} )} ), }; return ( {(data, key, colIndex) => { return ( {data[key]} ); }} ); }}
); }