From 6dd449f6f38e8afdee7638b56f24e61953854eda Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 9 Oct 2022 12:44:40 +0530 Subject: added item picker --- src/components/pickers/item-picker.js | 99 +++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'src/components/pickers/item-picker.js') diff --git a/src/components/pickers/item-picker.js b/src/components/pickers/item-picker.js index 8353dbb..46310db 100644 --- a/src/components/pickers/item-picker.js +++ b/src/components/pickers/item-picker.js @@ -15,8 +15,107 @@ * along with this program. If not, see . */ +import { Item, InvoiceItem, getAllItems } from '../../classes/item'; +import './scss/item-picker.scss'; + +import { useState, useEffect } from 'react'; +//import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +//import { faPhone, faEnvelope, faGlobe } from '@fortawesome/free-solid-svg-icons' + const ItemPicker = () => { + const [items, setItems] = useState([new Item()]); + const [item, setItem] = useState(new InvoiceItem()); + + useEffect(() => refreshItems, []); + + const refreshItems = () => + getAllItems(setItems, () => {}); + + const handleItemSelect = e => { + const i = items.find(i => i.Id === e.target.value); + setItem(prevItem => i ? ({...prevItem, ...i}) : new InvoiceItem()); + } + + const handleInput = e => { + const { name, value } = e.target; + setItem(prevItem => ({ + ...prevItem, + [name]: value + })); + } + return ( +
+

Add an Item

+
+ {items && items.length > 0 && + <> + + + + + + + + + } +
+
+
+ ); } export default ItemPicker; -- cgit v1.2.3