/* * 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 < 10 bugs // TODO: Implement override protection import React, { useState } from "react"; import axios from "axios"; 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(""); return (
{ 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}`) .then((res) => { console.log(res); }) .catch((err) => { console.log(err); }); props.updateItemsList(); } }>
{ props.setVisibility(false); } } />
); } export default RegisterItemForm;