import { Button, Bullseye } from '@patternfly/react-core' import PropTypes from 'prop-types' import React from 'react' import { useDispatch } from 'react-redux' import { useTopology } from '../../data/topology' import { Tr, Th, Thead, TableComposable, Td, ActionsColumn, Tbody } from '@patternfly/react-table' import { deleteRoom } from '../../redux/actions/topology/room' import TableEmptyState from '../util/TableEmptyState' function RoomTable({ projectId, topologyId, onSelect }) { const dispatch = useDispatch() const { status, data: topology } = useTopology(projectId, topologyId) const onDelete = (room) => dispatch(deleteRoom(room.id)) const actions = (room) => [ { title: 'Delete room', onClick: () => onDelete(room), }, ] return ( Name Tiles Racks {topology?.rooms.map((room) => { const tileCount = room.tiles.length const rackCount = room.tiles.filter((tile) => tile.rack).length return ( {tileCount === 1 ? '1 tile' : `${tileCount} tiles`} {rackCount === 1 ? '1 rack' : `${rackCount} racks`} ) })} {topology?.rooms.length === 0 && ( )} ) } RoomTable.propTypes = { projectId: PropTypes.number, topologyId: PropTypes.number, onSelect: PropTypes.func, } export default RoomTable