Update ReviewInvoice.js

This commit is contained in:
Victor Turgeon 2022-11-08 11:03:24 -05:00
parent 576152cc12
commit e5d0e9bead

View File

@ -59,6 +59,14 @@ const ReviewInvoice = () => {
const handleAddOne = (id) => {
var modifiedPQ = prodQuant.filter((pq) => pq.id == id);
var modifiedProd = prodQuant.filter((pq) => pq.product.id == id);
modifiedPQ.quantity++;
modifiedProd.quantity = modifiedPQ.quantity;
setProdQuant([...(prodQuant.filter((pq) => pq.id !== id)), { ...modifiedPQ }].sort((a, b) => a.id - b.id));
setProducts([...(products.filter((pq) => pq.product.id !== id)), { ...modifiedProd }].sort((a, b) => a.product.id - b.product.id));
}
@ -73,6 +81,7 @@ const ReviewInvoice = () => {
}
else {
modifiedPQ.quantity--;
modifiedProd.quantity = modifiedPQ.quantity;
setProdQuant([...(prodQuant.filter((pq) => pq.id !== id)), { ...modifiedPQ }].sort((a, b) => a.id - b.id));
setProducts([...(products.filter((pq) => pq.product.id !== id)), { ...modifiedProd }].sort((a, b) => a.product.id - b.product.id));
}