From 5ca14fcf3e949308eb0b2d636169e6601df1908d Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Wed, 28 Apr 2021 16:19:00 +0530 Subject: New Feature: Ability to register new items in the database --- src/components/Form/RegisterItemForm.js | 103 ++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/components/Form/RegisterItemForm.js (limited to 'src/components/Form/RegisterItemForm.js') diff --git a/src/components/Form/RegisterItemForm.js b/src/components/Form/RegisterItemForm.js new file mode 100644 index 0000000..1b38c8d --- /dev/null +++ b/src/components/Form/RegisterItemForm.js @@ -0,0 +1,103 @@ +/* + * OpenBills - Self hosted browser app to generate and keep track of simple invoices + * Version - 0 + * Licensed under the MIT license - https://opensource.org/licenses/MIT + * + * Copyright (c) 2021 Vidhu Kant Sharma +*/ + +// TODO: Code isn't tested properly +// I'd be surprised if it has no bugs + +import React, { useState } from "react"; +import axios from "axios"; +import "./Form.css"; + + +const RegisterItemForm = () => { + // show/hide this component + const [visibility, setVisibility] = useState(true)// useState(props.visibility); + + 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(""); + + + return ( +
+
{ + event.preventDefault(); + setVisibility(false); + + axios.post(`/api/items/?model=${newItemNameValue}&desc=${newItemDescValue}&price=${newItemPriceValue}&hsn=${newItemHSNValue}&gst=${newItemGSTValue}`) + .then((res) => { + console.log(res); + }) + .catch((err) => { + console.log(err); + }); + } + }> +
+ + + +
+ +
+ + + + + +
+ + +
+
+ ); +} + +export default RegisterItemForm; -- cgit v1.2.3