import React from 'react'; import PropTypes from 'prop-types'; import { withStyles } from '@material-ui/core/styles'; import classNames from 'classnames'; import AddIcon from '@material-ui/icons/Add'; import css from 'ba-styles/Table.scss'; import { Table, TableBody, TableCell, TableHead, TableRow, Toolbar, Typography, Tooltip, Button, } from '@material-ui/core'; import Row from './Row'; import styles from './tableStyle-jss'; class MainTable extends React.Component { render() { const { classes, items, addEmptyRow, removeRow, updateRow, editRow, finishEditRow, anchor, branch, title } = this.props; const getItems = dataArray => dataArray.map(item => ( updateRow(event, item, branch)} item={item} removeRow={() => removeRow(item, branch)} key={item.get('id')} editRow={() => editRow(item, branch)} finishEditRow={() => finishEditRow(item, branch)} branch={branch} /> )); const getHead = dataArray => dataArray.map((item, index) => { if (!item.hidden) { return ( {item.label} ); } return false; }); return (
{title}
{ getHead(anchor) } {getItems(items)}
); } } MainTable.propTypes = { title: PropTypes.string.isRequired, classes: PropTypes.object.isRequired, items: PropTypes.object.isRequired, anchor: PropTypes.array.isRequired, addEmptyRow: PropTypes.func.isRequired, removeRow: PropTypes.func.isRequired, updateRow: PropTypes.func.isRequired, editRow: PropTypes.func.isRequired, finishEditRow: PropTypes.func.isRequired, branch: PropTypes.string.isRequired }; export default withStyles(styles)(MainTable);