import Link from 'next/link'; import { Button, Icon, Icons, Modal, ModalTrigger, Text } from 'react-basics'; import TeamDeleteForm from './TeamDeleteForm'; import TeamLeaveForm from './TeamLeaveForm'; import useMessages from 'hooks/useMessages'; import useUser from 'hooks/useUser'; import { ROLES } from 'lib/constants'; import SettingsTable from 'components/common/SettingsTable'; import useLocale from 'hooks/useLocale'; export function TeamsTable({ data = [], onDelete }) { const { formatMessage, labels } = useMessages(); const { user } = useUser(); const { dir } = useLocale(); const columns = [ { name: 'name', label: formatMessage(labels.name) }, { name: 'owner', label: formatMessage(labels.owner) }, { name: 'action', label: ' ' }, ]; const cellRender = (row, data, key) => { if (key === 'owner') { return row.teamUser.find(({ role }) => role === ROLES.teamOwner)?.user?.username; } return data[key]; }; return ( {row => { const { id, teamUser } = row; const owner = teamUser.find(({ role }) => role === ROLES.teamOwner); const showDelete = user.id === owner?.userId; return ( <> {showDelete && ( {close => ( )} )} {!showDelete && ( {close => ( )} )} ); }} ); } export default TeamsTable;