fix(cart): remove product when count zero

This commit is contained in:
Ayo 2024-01-22 23:18:53 +01:00
parent df661089e5
commit a0daa29871

View file

@ -55,6 +55,11 @@ class Cart extends Component {
if (index > -1) {
const updatedProducts = [...products];
updatedProducts[index].count--;
if (updatedProducts[index].count === 0) {
updatedProducts.splice(index, 1);
}
this.setState({ products: updatedProducts });
}
};