Skip to content

Commit

Permalink
14. delete cart item
Browse files Browse the repository at this point in the history
  • Loading branch information
bbandydd committed Jul 28, 2017
1 parent 7fde022 commit 3398396
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/containers/Home/components/Content.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ export default class Content extends Component {
});
}

deleteCartItem = (index) => {
const cart = this.state.cart;
cart.splice(index, 1);

this.setState({
cart
});
}

render() {
const { album, cart, modal } = this.state;

Expand Down Expand Up @@ -94,6 +103,7 @@ export default class Content extends Component {
<th>#</th>
<th>品項</th>
<th>價格</th>
<th />
</tr>
</thead>
<tbody>
Expand All @@ -103,6 +113,7 @@ export default class Content extends Component {
<th scope="row">{index + 1}</th>
<td>{item.title}</td>
<td>{item.price}</td>
<td><Button color="danger" onClick={() => this.deleteCartItem(index)}>X</Button>{' '}</td>
</tr>
))
}
Expand Down

0 comments on commit 3398396

Please sign in to comment.