diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-09-27 21:42:51 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-09-27 21:42:51 +0530 |
commit | 39819430fa47172c1a3a36218339f6baf86f8983 (patch) | |
tree | dafe65a48fcceb60b588c613e2d92be4c514633b /src/views/manage/items.js | |
parent | 072e53f0b2eb8fa14c0aa49286193784c73257cb (diff) |
added edit option for items and brands
Diffstat (limited to 'src/views/manage/items.js')
-rw-r--r-- | src/views/manage/items.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/views/manage/items.js b/src/views/manage/items.js index b9bf339..567be7c 100644 --- a/src/views/manage/items.js +++ b/src/views/manage/items.js @@ -22,11 +22,12 @@ import { useState, useEffect } from 'react'; import './scss/management-page.scss' -import { getAllItems } from '../../classes/item'; +import { Item, getAllItems } from '../../classes/item'; import ItemEditor from './../../components/editors/item-editor'; import ItemTable from './../../components/tables/item-table'; const ManageItemsPage = () => { + const [itemToEdit, setItemToEdit] = useState(new Item()); const [allItems, setAllItems] = useState([]); // TODO: handle error const updateList = () => @@ -38,9 +39,27 @@ const ManageItemsPage = () => { return ( <> - <ItemEditor heading={"Add New Item"} callback={updateList}/> + <ItemEditor + heading={"Add New Item"} + item={new Item()} + callback={updateList}/> <hr/> - <ItemTable refresh={updateList} items={allItems}/> + <ItemTable + refresh={updateList} + items={allItems} + setItemToEdit={setItemToEdit}/> + + {JSON.stringify(itemToEdit) !== JSON.stringify(new Item()) && + <div className={"floating-wrapper"}> + <ItemEditor + className={"floating-window"} + heading={`Edit ${itemToEdit.Name ? itemToEdit.Name : 'Item'}:`} + item={itemToEdit} + hide={() => setItemToEdit(new Item())} + editing={true} + callback={updateList}/> + </div> + } </> ); } |