From 2f9d7e2584330fdabc351ea3d04bade1104e5aa5 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Fri, 2 Jul 2021 20:09:09 +0530 Subject: Bug fix: the GST reset button appearing when item was added --- src/components/Form/Items/AddNewItemForm.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/Form/Items/AddNewItemForm.tsx b/src/components/Form/Items/AddNewItemForm.tsx index 7060f51..d3c873f 100644 --- a/src/components/Form/Items/AddNewItemForm.tsx +++ b/src/components/Form/Items/AddNewItemForm.tsx @@ -29,13 +29,16 @@ const AddNewItemForm: React.FC = (props) => { const [itemQTYValue, setItemQTYValue] = useState(1); const [itemHSNValue, setItemHSNValue] = useState(""); - // store the current item to easily reset a value to the default one - const [currentItem, setCurrentItem] = useState({ + // default item object + const defaultItem: any = { Description: "", UnitPrice: 0.00, - GSTPercentage: props.defGSTValue, + TotalGST: props.defGSTValue, HSN: "" - }); + } + + // store the current item to easily reset a value to the default one + const [currentItem, setCurrentItem] = useState(defaultItem); // to be handled by DocumentInfo // check if client is in same state @@ -67,10 +70,11 @@ const AddNewItemForm: React.FC = (props) => { setItemNameValue(""); setItemDescValue(""); setItemQTYValue(1); - setItemPriceValue(1); + setItemPriceValue(0); setItemDiscountPercentage(0); setItemHSNValue(""); setItemGSTPercentage(props.defGSTValue); + setCurrentItem(defaultItem); } return ( -- cgit v1.2.3