From 8ab93681fddf6c104d02f5123e293a5da25b311b Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Thu, 15 Apr 2021 17:33:18 +0530 Subject: Added more basic functionality for BillingForm --- src/components/App.js | 18 ++++++------- src/components/Form/Form.js | 61 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 22 deletions(-) (limited to 'src/components') diff --git a/src/components/App.js b/src/components/App.js index 3d184b2..c1bae4f 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -5,21 +5,17 @@ import BillingForm from "./Form/Form.js"; const sampleData = [ { "Model": "Kisan Chair", - "Description":"Very good chair", - "Price":"10000", - "Discount":"3%",}, - { + "Description": "Very good chair", + "Price": "10000", + "Discount": ""} + , { "Model": "Supreme Chair", - "Description":"Even better chair", - "Price":"2134983", - "Discount":"9%", + "Description": "Even better chair", + "Price": "2134983", + "Discount": "" } ] -console.log("sample data:", sampleData); - - - const App = () => { return ( <> diff --git a/src/components/Form/Form.js b/src/components/Form/Form.js index 3285548..5cb5675 100644 --- a/src/components/Form/Form.js +++ b/src/components/Form/Form.js @@ -3,43 +3,82 @@ import "./Form.css"; const BillingForm = (props) => { - const [itemValue, setItemValue] = useState(""); - const [descValue, setDescValue] = useState(""); + const [itemNameValue, setItemNameValue] = useState(""); + const [itemDescValue, setItemDescValue] = useState(""); + const [itemPriceValue, setItemPriceValue] = useState(0.00); + const [itemDiscountValue, setItemDiscountValue] = useState(0.00); + const [itemGSTValue, setItemGSTValue] = useState(18); + // Extract the model names from savedItems const savedItems = props.savedItems; - let savedItemNames = [] + let savedItemNames = []; for (let i = 0; i < savedItems.length; i++) { - savedItemNames.push(savedItems[i].Model) + savedItemNames.push(savedItems[i].Model); } const filteredItems = savedItemNames.filter( (item) => { // case insensitive - return item.toLowerCase().includes(itemValue.toLowerCase()); + return item.toLowerCase().includes(itemNameValue.toLowerCase()); } ); - + return (
{ event.preventDefault(); - console.log(itemValue, descValue); + console.log(itemNameValue, itemDescValue, itemPriceValue); } }> + + + + + + -- cgit v1.2.3