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 RowReadOnly from './RowReadOnly'; import styles from './tableStyle-jss'; class MainTableForm extends React.Component { render() { const { title, classes, items, removeRow, editRow, addNew, anchor, branch, removeRowAPI } = this.props; const getItems = dataArray => dataArray.map(item => ( removeRow(item, branch)} key={item.get('id')} editRow={() => editRow(item, branch)} anchor={anchor} branch={branch} removeRowAPI = {removeRowAPI} /> )); const getHead = dataArray => dataArray.map((item, index) => { if (!item.hidden) { return ( {item.label} ); } return false; }); return (
{title}
{ getHead(anchor) } {getItems(items)}
); } } MainTableForm.propTypes = { title: PropTypes.string.isRequired, classes: PropTypes.object.isRequired, items: PropTypes.object.isRequired, anchor: PropTypes.array.isRequired, addNew: PropTypes.func.isRequired, removeRow: PropTypes.func.isRequired, editRow: PropTypes.func.isRequired, branch: PropTypes.string.isRequired, }; export default withStyles(styles)(MainTableForm);