Skip to content

Commit

Permalink
Merge pull request vercel#9 from chec/bugfix/cart-update-remove-actions
Browse files Browse the repository at this point in the history
Bugfix/cart update remove actions
  • Loading branch information
john-raymon committed Apr 28, 2020
2 parents c4a041e + 2cb6529 commit 290c1f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions components/cart/CartItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class CartItem extends Component {
/**
* Update cart item
*/
handleUpdateCartItem(lineItem) {
this.props.dispatch(updateCartItem(lineItem));
handleUpdateCartItem(lineItem, quantity) {
this.props.dispatch(updateCartItem(lineItem, quantity));
}

/**
Expand Down Expand Up @@ -51,15 +51,15 @@ class CartItem extends Component {
</div>
<div className="d-flex align-items-center justify-content-between pt-2 pb-4">
<div className="d-flex align-items-center">
<button className="p-0 bg-transparent" onClick={item.quantity > 1 ? this.handleUpdateCartItem(item.id, item.quantity -1) : this.handleRemoveFromCart(item.id)}>
<button className="p-0 bg-transparent" onClick={() => item.quantity > 1 ? this.handleUpdateCartItem(item.id, item.quantity -1) : this.handleRemoveFromCart(item.id)}>
<img src="/icon/minus.svg" className="w-16" />
</button>
<p className="text-center px-3">{item.quantity}</p>
<button className="p-0 bg-transparent" onClick={this.handleUpdateCartItem(item.id, item.quantity + 1)} >
<button className="p-0 bg-transparent" onClick={() => this.handleUpdateCartItem(item.id, item.quantity +1)} >
<img src="/icon/plus.svg" className="w-16" />
</button>
</div>
<p className="text-right text-decoration-underline font-color-medium cursor-pointer" onClick={this.handleRemoveFromCart(item.id)}>
<p className="text-right text-decoration-underline font-color-medium cursor-pointer" onClick={() => this.handleRemoveFromCart(item.id)}>
Remove
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion store/actions/cartActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const updateCartItemSuccess = (item) => {

export const updateCartItem = (lineItemId, quantity) => async (dispatch) => {
try {
const item = await commerce.cart.update(lineItemId, quantity);
const item = await commerce.cart.update(lineItemId, { quantity });
dispatch(updateCartItemSuccess(item))
} catch (err) {
console.log('error updating cart item', err)
Expand Down

0 comments on commit 290c1f8

Please sign in to comment.