diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-10-12 21:04:39 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-10-12 21:04:39 +0530 |
commit | 300a4eb39ccea56da416d83400cddc97118e1649 (patch) | |
tree | 9ba1dc0c4f8d64bce52ba9a9fd9a73ac5d090103 /src/views | |
parent | 0b4343bed2cace86552929f25202680c0d99c541 (diff) |
showing total (sum) values in InvoiceItemTable
Diffstat (limited to 'src/views')
-rw-r--r-- | src/views/invoice/new.js | 13 |
1 files changed, 9 insertions, 4 deletions
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])} /> <ItemTable items={items} - setItems={setItems} /> + setItems={setItems} + isInterstate={isInterstate} + sum={sum} /> </> ); } |