From 39819430fa47172c1a3a36218339f6baf86f8983 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Tue, 27 Sep 2022 21:42:51 +0530 Subject: added edit option for items and brands --- src/views/manage/brands.js | 25 ++++++++++++++++++++++--- src/views/manage/items.js | 25 ++++++++++++++++++++++--- src/views/manage/scss/management-page.scss | 4 ++++ 3 files changed, 48 insertions(+), 6 deletions(-) (limited to 'src/views') diff --git a/src/views/manage/brands.js b/src/views/manage/brands.js index 61afe16..dad21e2 100644 --- a/src/views/manage/brands.js +++ b/src/views/manage/brands.js @@ -18,11 +18,12 @@ import { useState, useEffect } from 'react'; import './scss/management-page.scss' -import { getAllBrands } from '../../classes/brand'; +import { Brand, getAllBrands } from '../../classes/brand'; import BrandEditor from './../../components/editors/brand-editor'; import BrandTable from './../../components/tables/brand-table'; const ManageBrandsPage = () => { + const [brandToEdit, setBrandToEdit] = useState(new Brand()); const [allBrands, setAllBrands] = useState([]); // TODO: handle error const updateList = () => @@ -34,9 +35,27 @@ const ManageBrandsPage = () => { return ( <> - +
- + + + {JSON.stringify(brandToEdit) !== JSON.stringify(new Brand()) && +
+ setBrandToEdit(new Brand())} + editing={true} + callback={updateList}/> +
+ } ); } 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 ( <> - +
- + + + {JSON.stringify(itemToEdit) !== JSON.stringify(new Item()) && +
+ setItemToEdit(new Item())} + editing={true} + callback={updateList}/> +
+ } ); } diff --git a/src/views/manage/scss/management-page.scss b/src/views/manage/scss/management-page.scss index df26819..656d224 100644 --- a/src/views/manage/scss/management-page.scss +++ b/src/views/manage/scss/management-page.scss @@ -15,6 +15,10 @@ * along with this program. If not, see . */ +@import "../../../styles"; + +@include floating-window; + hr { margin: 0.8rem auto 1rem auto; } -- cgit v1.2.3