From 03a991b1c59e010253f8673a4aa82c89f7bc7d13 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Fri, 16 Apr 2021 17:37:07 +0530 Subject: added validation to AddNewItemForm --- src/components/BillingPage.js | 10 +++--- src/components/Form/AddNewItemForm.js | 63 ++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/components/BillingPage.js b/src/components/BillingPage.js index 066b30b..f4b2b11 100644 --- a/src/components/BillingPage.js +++ b/src/components/BillingPage.js @@ -6,18 +6,18 @@ const sampleData = [ { "Model": "Kisan Chair", "Description": "Very good chair", - "Price": "10000", - "Discount": "" + "Price": 10000, + "Discount": 0 }, { "Model": "Supreme Chair", "Description": "Even better chair", "Price": "2134983", - "Discount": "" + "Discount": 0 }, { "Model": "Action Houseware", "Description": "Not a chair", - "Price": "69", - "Discount": "" + "Price": 69, + "Discount": 0 } ]; diff --git a/src/components/Form/AddNewItemForm.js b/src/components/Form/AddNewItemForm.js index 8484724..5d0b224 100644 --- a/src/components/Form/AddNewItemForm.js +++ b/src/components/Form/AddNewItemForm.js @@ -22,13 +22,6 @@ const AddNewItemForm = (props) => { savedItemNames.push(savedItems[i].Model); } - const filteredItems = savedItemNames.filter( - (item) => { - // case insensitive - return item.toLowerCase().includes(itemNameValue.toLowerCase()); - } - ); - // set description and price // when item is entered const setItemInfo = (itemName) => { @@ -50,7 +43,15 @@ const AddNewItemForm = (props) => {
{ event.preventDefault(); - console.log(itemNameValue, itemDescValue, itemPriceValue); + const newInvoiceItem = { + "Model": itemNameValue, + "Description": itemDescValue, + "Quantity": itemQtyValue, + "Price": itemPriceValue, + "Discount": itemDiscountValue, + "GST": itemGSTValue + }; + console.log(newInvoiceItem); } }>
@@ -63,7 +64,7 @@ const AddNewItemForm = (props) => { setItemNameValue(event.target.value); setItemInfo(event.target.value.toLowerCase()); } - }> + } > {savedItemNames.map( (i) => { @@ -72,11 +73,10 @@ const AddNewItemForm = (props) => { )} -
-- cgit v1.2.3