From 5f9cdac0d2f0522cacc092b1fcde523cddf3d97f Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Fri, 30 Apr 2021 08:38:46 +0530 Subject: fixed RegisterItemForm not showing/hiding --- src/components/Form/RegisterItemForm.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/components/Form') diff --git a/src/components/Form/RegisterItemForm.js b/src/components/Form/RegisterItemForm.js index ddc3eff..fe7b13d 100644 --- a/src/components/Form/RegisterItemForm.js +++ b/src/components/Form/RegisterItemForm.js @@ -17,10 +17,6 @@ import "./Form.css"; const RegisterItemForm = (props) => { - // show/hide this component - // experimental - const [visibility, setVisibility] = useState(true); - const [newItemNameValue, setNewItemNameValue] = useState(""); const [newItemDescValue, setNewItemDescValue] = useState(""); // const [newItemBrandValue, setNewItemBrandValue] = useState(""); @@ -31,16 +27,13 @@ const RegisterItemForm = (props) => { return ( -
+
{ event.preventDefault(); - // experimental - // make sure it shows confirmation - // before hiding itself - setVisibility(false); - + // TODO: show confirmation before being invisible + props.setVisibility(false); axios.post(`/api/items/?model=${newItemNameValue}&desc=${newItemDescValue}&price=${newItemPriceValue}&hsn=${newItemHSNValue}&gst=${newItemGSTValue}`) .then((res) => { console.log(res); @@ -106,7 +99,7 @@ const RegisterItemForm = (props) => { value="cancel" onClick={ () => { - setVisibility(false); + props.setVisibility(false); } } /> -- cgit v1.2.3