diff --git a/src/components/Board.js b/src/components/Board.js index 92f215a..3cafe22 100644 --- a/src/components/Board.js +++ b/src/components/Board.js @@ -24,6 +24,16 @@ class Board extends Component { })); } + handleRemoveList = (listId) => { + let array = [...this.state.lists]; // Make a separate copy of the array + const index = array.findIndex(l => l.id === listId); // find the index of the list item I want to remove + + if (index > -1) { // item found? + array.splice(index, 1); // remove item + this.setState({ lists: array }); // update state without that item + } + } + render() { return (
@@ -37,7 +47,7 @@ class Board extends Component {
{ this.state.lists.map((list) => { - return + return }) } diff --git a/src/components/ListTile.js b/src/components/ListTile.js index aa4c6a7..cea5182 100644 --- a/src/components/ListTile.js +++ b/src/components/ListTile.js @@ -16,6 +16,16 @@ class ListTile extends Component { })); } + deleteList = () => { + fetch(`/boards/${this.props.boardId}/lists/${this.props.id}`, { + method: 'DELETE' + }).then(res => { + if (res.ok && res.status === 204) { + this.props.onListDeletion(this.props.id); + } + }); + } + newCardTextChange = (e) => { this.setState({ newCardText: e.target.value @@ -52,6 +62,8 @@ class ListTile extends Component {
{this.props.name} + + Delete