react-version #1
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user