import React, { Component } from 'react'
import { Card, Button, Icon } from 'semantic-ui-react'
import CreateTableForm from '../CreateTable/CreateTableForm'
import TableListItem from './TableListItem'
import './TableList.css'
import Tables from '../../Models/Tables'
import TableListController from '../../Controllers/TableListController'
class TableList extends Component {
constructor () {
super()
this.tables = new Tables()
this.controller = new TableListController()
this.state = {
adding: false,
tables: this.tables.getCollectionProps()
}
document.addEventListener('updateTables', this.updateTableList)
}
toggleAddingTable = () => { this.setState({ adding: !this.state.adding }) }
updateTableList = () => {
this.setState({tables: this.tables.getCollectionProps()})
}
renderTableListElements = () => {
const { tables } = this.state
const tableListElements = tables.map(t =>