From a008767f428e81669efbfa24497c613c592c361c Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Wed, 14 Apr 2021 21:56:22 +0530 Subject: now the products are passed in as props in JSON format --- src/components/Form/Form.js | 91 ++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 43 deletions(-) (limited to 'src/components/Form') diff --git a/src/components/Form/Form.js b/src/components/Form/Form.js index 1261e4b..3285548 100644 --- a/src/components/Form/Form.js +++ b/src/components/Form/Form.js @@ -1,55 +1,60 @@ import React, { useState } from "react"; import "./Form.css"; -const BillingForm = () => { - /* - const sampleData = [ - { - "Model": "Kisan Chair", - "Description":"Very good chair", - "Price":"10000", - "Discount":"3%" - }, - { - "Model": "Supreme Chair", - "Description":"Even better chair", - "Price":"2134983", - "Discount":"9%" - } - ] - */ + +const BillingForm = (props) => { const [itemValue, setItemValue] = useState(""); const [descValue, setDescValue] = useState(""); + const savedItems = props.savedItems; + let savedItemNames = [] + for (let i = 0; i < savedItems.length; i++) { + savedItemNames.push(savedItems[i].Model) + } - + const filteredItems = savedItemNames.filter( + (item) => { + // case insensitive + return item.toLowerCase().includes(itemValue.toLowerCase()); + } + ); + return ( -
{ - event.preventDefault(); - console.log(itemValue, descValue); - } - }> - -