From 5846185f5a6662265c5330fbed229f49efb26b89 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Mon, 3 May 2021 12:26:47 +0530 Subject: added some features and many bugs to DocumentInfoForm --- src/components/Form/Document/DocumentInfoForm.js | 191 +++++------------------ src/components/Form/Items/AddNewItemForm.js | 8 +- 2 files changed, 43 insertions(+), 156 deletions(-) (limited to 'src/components/Form') diff --git a/src/components/Form/Document/DocumentInfoForm.js b/src/components/Form/Document/DocumentInfoForm.js index a3f70b7..0b133c6 100644 --- a/src/components/Form/Document/DocumentInfoForm.js +++ b/src/components/Form/Document/DocumentInfoForm.js @@ -10,31 +10,30 @@ import React, { useState } from "react"; import "./../Form.scss"; -const AddNewItemForm = (props) => { - const [itemNameValue, setItemNameValue] = useState(""); - const [itemDescValue, setItemDescValue] = useState(""); - const [itemPriceValue, setItemPriceValue] = useState(0.00); - const [itemDiscountValue, setItemDiscountValue] = useState(0.00); - const [itemGSTValue, setItemGSTValue] = useState(props.defGSTValue); - const [itemQtyValue, setItemQtyValue] = useState(1); - const [itemHSNValue, setItemHSNValue] = useState(0); +const DocumentInfoForm = (props) => { + const [clientName, setClientName] = useState(0); + /* TODO: implement a way such that the database also + * gives the ID of the client and all the functions + * are carried out from the ID because if two people + * with same name are added then this shit is done for + */ - const [itemToAdd, setItemToAdd] = useState({}); + const selectPersonPrompt = "start typing here"; + const registerPersonPrompt = "add new"; - const enterItemNamePrompt = "start typing here"; - const registerItemPrompt = "add new"; - const emptyItemNames = [enterItemNamePrompt, registerItemPrompt, ""]; + // const emptyPersonNames = [enterItemNamePrompt, registerItemPrompt, ""]; // Extract the model names from savedItems - let savedItemNames= []; + let savedPeopleNames = []; if (props.savedItems !== null) { - for (let i = 0; i < props.savedItems.length; i++) { - savedItemNames.push(props.savedItems[i].Model); + for (let i = 0; i < props.savedPeople.length; i++) { + savedPeopleNames.push(props.savedPeople[i].Name); } } // set description and price // when item is entered + /* const setItemInfo = (itemName) => { for (let i = 0; i < props.savedItems.length; i++) { const mod = props.savedItems[i].Model.toLowerCase(); @@ -52,7 +51,9 @@ const AddNewItemForm = (props) => { } } } + */ + /* const resetAllValues = () => { setItemNameValue(""); setItemDescValue(""); @@ -62,145 +63,31 @@ const AddNewItemForm = (props) => { setItemHSNValue(0); setItemGSTValue(props.defGSTValue); } + */ return ( -
-
{ - event.preventDefault(); - const newInvoiceItem = { - "Model": itemNameValue, - "Description": itemDescValue, - "Quantity": parseInt(itemQtyValue), - "UnitPrice": parseFloat(itemPriceValue), - "TotalPrice": parseFloat(itemPriceValue * itemQtyValue), - "Discount": parseInt(itemDiscountValue), - "HSN": parseInt(itemHSNValue), - "GST": parseInt(itemGSTValue) - }; - props.addItem(newInvoiceItem); - resetAllValues(); - } - }> -
- - - -
- -
- - - - - - - - - -
- -
- props.registerFormVisibility(true)} - /> - - - - - - + Client Name: + + + ); } -export default AddNewItemForm; +export default DocumentInfoForm; diff --git a/src/components/Form/Items/AddNewItemForm.js b/src/components/Form/Items/AddNewItemForm.js index 4eaea7d..78d1437 100644 --- a/src/components/Form/Items/AddNewItemForm.js +++ b/src/components/Form/Items/AddNewItemForm.js @@ -181,13 +181,13 @@ const AddNewItemForm = (props) => {
props.registerItemFormVisibility(true)} + value="Register New Client" + onClick={() => props.registerPersonFormVisibility(true)} /> props.registerPersonFormVisibility(true)} + value="Register New Item" + onClick={() => props.registerItemFormVisibility(true)} /> -- cgit v1.2.3