From 300a4eb39ccea56da416d83400cddc97118e1649 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Wed, 12 Oct 2022 21:04:39 +0530 Subject: showing total (sum) values in InvoiceItemTable --- src/views/invoice/new.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/views/invoice') diff --git a/src/views/invoice/new.js b/src/views/invoice/new.js index 70bc545..1d162ad 100644 --- a/src/views/invoice/new.js +++ b/src/views/invoice/new.js @@ -20,6 +20,7 @@ import ItemPicker from '../../components/pickers/item-picker'; import ItemTable from '../../components/tables/invoice-item-table'; import { InvoiceClient } from '../../classes/client'; +import { calcSum } from '../../classes/item'; import { useState, useEffect } from 'react'; @@ -27,10 +28,12 @@ const NewInvoicePage = () => { const [client, setClient] = useState(new InvoiceClient()); const [shippingAddressId, setShippingAddressId] = useState(-1); const [items, setItems] = useState([]); + const [isInterstate, setIsInterstate] = useState(false); + const [sum, setSum] = useState({}); - useEffect(() => { - setShippingAddressId(-1); - }, [client]); + useEffect(() => setShippingAddressId(-1), [client]); + + useEffect(() => setSum(calcSum(items)), [items]); return ( <> @@ -44,7 +47,9 @@ const NewInvoicePage = () => { addInvoiceItem={(item) => setItems(prev => [...prev, item])} /> + setItems={setItems} + isInterstate={isInterstate} + sum={sum} /> ); } -- cgit v1.2.3