Skip to content

Commit

Permalink
The "Plus" button to increase the quantity of product in shopping car…
Browse files Browse the repository at this point in the history
…t not work (#817)
  • Loading branch information
nashtech-tuannguyenhuu1 authored Aug 1, 2024
1 parent 904a175 commit 642cc92
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions storefront/pages/cart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ConfirmationDialog from '@/common/components/dialog/ConfirmationDialog';
import { useCartContext } from '@/context/CartContext';
import { Cart as CartModel } from '@/modules/cart/models/Cart';
import {
addToCart,
getCart,
getCartProductThumbnail,
removeProductInCart,
Expand Down Expand Up @@ -113,16 +112,14 @@ const Cart = () => {
setIsOpenRemoveDialog(false);
};

const handlePlus = (productId: number) => {
addToCart([
{
productId: productId,
quantity: 1,
},
])
const handlePlus = (productId: number, productQuantity: number) => {
updateCart({
productId: productId,
quantity: productQuantity + 1,
})
.then(() => loadCart())
.catch((err) => {
console.log('Add to cart fail: ' + err.message);
console.log('Plus product to cart fail: ' + err.message);
});
};

Expand Down Expand Up @@ -316,7 +313,7 @@ const Cart = () => {
type="button"
value="+"
className="plus"
onClick={() => handlePlus(item.productId)}
onClick={() => handlePlus(item.productId, item.quantity)}
/>
</div>
</div>
Expand Down

0 comments on commit 642cc92

Please sign in to comment.