From b6dfe84ecbb14da9b0c6c2d4aef4a34692e4abc3 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Fri, 30 Apr 2021 10:33:49 +0530 Subject: cleaned the code and implemented shitty error handling --- src/components/Form/RegisterItemForm.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/components/Form') diff --git a/src/components/Form/RegisterItemForm.js b/src/components/Form/RegisterItemForm.js index fe7b13d..864a146 100644 --- a/src/components/Form/RegisterItemForm.js +++ b/src/components/Form/RegisterItemForm.js @@ -19,11 +19,11 @@ import "./Form.css"; const RegisterItemForm = (props) => { const [newItemNameValue, setNewItemNameValue] = useState(""); const [newItemDescValue, setNewItemDescValue] = useState(""); - // const [newItemBrandValue, setNewItemBrandValue] = useState(""); - // const [newItemTypeValue, setNewItemTypeValue] = useState(""); const [newItemPriceValue, setNewItemPriceValue] = useState(""); const [newItemHSNValue, setNewItemHSNValue] = useState(""); const [newItemGSTValue, setNewItemGSTValue] = useState(""); + // const [newItemBrandValue, setNewItemBrandValue] = useState(""); + // const [newItemTypeValue, setNewItemTypeValue] = useState(""); return ( @@ -33,10 +33,17 @@ const RegisterItemForm = (props) => { event.preventDefault(); // TODO: show confirmation before being invisible - props.setVisibility(false); - axios.post(`/api/items/?model=${newItemNameValue}&desc=${newItemDescValue}&price=${newItemPriceValue}&hsn=${newItemHSNValue}&gst=${newItemGSTValue}`) + axios.post( + `/api/items/` + + `?model=${newItemNameValue}` + + `&desc=${newItemDescValue}` + + `&price=${newItemPriceValue}` + + `&hsn=${newItemHSNValue}` + + `&gst=${newItemGSTValue}` + ) .then((res) => { console.log(res); + props.setVisibility(false); }) .catch((err) => { console.log(err); -- cgit v1.2.3