From ee77e57189a6b0375e840b386754973a376dc089 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Sat, 17 Apr 2021 19:04:55 +0530 Subject: added a way to see the total cost and number of items in ItemsDisplay --- src/components/Form/AddNewItemForm.js | 22 +++++++++++----------- src/components/Form/Form.css | 11 +++++++++++ src/components/Form/Form.scss | 13 +++++++++++++ 3 files changed, 35 insertions(+), 11 deletions(-) (limited to 'src/components/Form') diff --git a/src/components/Form/AddNewItemForm.js b/src/components/Form/AddNewItemForm.js index 07b3092..09536b1 100644 --- a/src/components/Form/AddNewItemForm.js +++ b/src/components/Form/AddNewItemForm.js @@ -25,15 +25,15 @@ const AddNewItemForm = (props) => { // set description and price // when item is entered const setItemInfo = (itemName) => { - for (let i = 0; i <= props.savedItems.length - 1; i++) { - const mod = props.savedItems[i].Model.toLowerCase(); - const desc = props.savedItems[i].Description; - const price = props.savedItems[i].Price; + for (let i = 0; i < props.savedItems.length - 1; i++) { + const mod = props.savedItems[i].Model.toLowerCase(); + const desc = props.savedItems[i].Description; + const price = props.savedItems[i].Price; - if (mod === itemName) { - setItemDescValue(desc); - setItemPriceValue(price); - break; + if (mod === itemName) { + setItemDescValue(desc); + setItemPriceValue(price); + break; } } } @@ -56,7 +56,7 @@ const AddNewItemForm = (props) => { "Model": itemNameValue, "Description": itemDescValue, "Quantity": parseInt(itemQtyValue), - "Price": parseInt(itemPriceValue), + "Price": parseFloat(itemPriceValue), "Discount": parseInt(itemDiscountValue), "GST": parseInt(itemGSTValue) }; @@ -105,7 +105,7 @@ const AddNewItemForm = (props) => {