From a41ba5a109f849dcdb8254d25819ccb859dd3709 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 17 Jan 2024 16:09:18 +0300 Subject: [PATCH 1/2] Handle Vertical stock item tables - add index to toggle between them and route to packaging after stock item addition, removed closeOverlay for deactivated transisitions from save to edit --- .../add-stock-item/add-stock-item.component.tsx | 12 +++++++++--- .../stock-item-details.component.tsx | 4 ++-- src/stock-items/stock-item.utils.tsx | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/stock-items/add-stock-item/add-stock-item.component.tsx b/src/stock-items/add-stock-item/add-stock-item.component.tsx index a2f66007..0cc565dd 100644 --- a/src/stock-items/add-stock-item/add-stock-item.component.tsx +++ b/src/stock-items/add-stock-item/add-stock-item.component.tsx @@ -23,8 +23,8 @@ const AddEditStockItem: React.FC = ({ }) => { const { t } = useTranslation(); const [selectedTab, setSelectedTab] = useState(0); - const handleTabChange = () => { - setSelectedTab((prevState) => prevState + 1); + const handleTabChange = (index: number) => { + setSelectedTab(index); }; const tabs: TabItem[] = [ { @@ -65,7 +65,13 @@ const AddEditStockItem: React.FC = ({ // }, ]; - return ; + return ( + + ); }; export default AddEditStockItem; diff --git a/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx b/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx index 4edbbd46..b881a546 100644 --- a/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +++ b/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx @@ -27,7 +27,7 @@ interface StockItemDetailsProps { model: StockItemDTO; onSave: SaveStockItem; isEditing?: boolean; - handleTabChange: () => void; + handleTabChange: (index) => void; } const StockItemDetails = forwardRef( @@ -47,7 +47,7 @@ const StockItemDetails = forwardRef( // Restore uuid item.uuid = model.uuid; await onSave(item); - handleTabChange(); + handleTabChange(1); } catch (e) { // Show notification } finally { diff --git a/src/stock-items/stock-item.utils.tsx b/src/stock-items/stock-item.utils.tsx index 3da18594..6bcd692a 100644 --- a/src/stock-items/stock-item.utils.tsx +++ b/src/stock-items/stock-item.utils.tsx @@ -29,7 +29,7 @@ export const addOrEditStockItem = async ( }); // Close overlay and open edit overlay - closeOverlay(); + //closeOverlay(); if (!isEditing) { closeOverlay(); From 402d9cf7fc044580c6864e209e3c90506addceaa Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 17 Jan 2024 16:37:11 +0300 Subject: [PATCH 2/2] Re routed to stock items after adding packaging units, removed commented code --- .../add-stock-item/add-stock-item.component.tsx | 7 ++++++- .../packaging-units/packaging-units.component.tsx | 7 ++++++- src/stock-items/stock-item.utils.tsx | 3 --- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/stock-items/add-stock-item/add-stock-item.component.tsx b/src/stock-items/add-stock-item/add-stock-item.component.tsx index 0cc565dd..7f69f7be 100644 --- a/src/stock-items/add-stock-item/add-stock-item.component.tsx +++ b/src/stock-items/add-stock-item/add-stock-item.component.tsx @@ -40,7 +40,12 @@ const AddEditStockItem: React.FC = ({ }, { name: t("packagingUnits", "Packaging Units"), - component: , + component: ( + + ), disabled: !isEditing, }, { diff --git a/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx b/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx index a5236e7f..4a7e55c6 100644 --- a/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +++ b/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx @@ -33,9 +33,13 @@ import { useTranslation } from "react-i18next"; interface PackagingUnitsProps { onSubmit?: () => void; stockItemUuid: string; + handleTabChange: (index) => void; } -const PackagingUnits: React.FC = ({ stockItemUuid }) => { +const PackagingUnits: React.FC = ({ + stockItemUuid, + handleTabChange, +}) => { const { items, isLoading, tableHeaders, setStockItemUuid } = useStockItemPackageUnitsHook(); useEffect(() => { @@ -79,6 +83,7 @@ const PackagingUnits: React.FC = ({ stockItemUuid }) => { }); } ); + handleTabChange(0); }; if (isLoading) diff --git a/src/stock-items/stock-item.utils.tsx b/src/stock-items/stock-item.utils.tsx index 6bcd692a..b8cab1cf 100644 --- a/src/stock-items/stock-item.utils.tsx +++ b/src/stock-items/stock-item.utils.tsx @@ -28,9 +28,6 @@ export const addOrEditStockItem = async ( } Successfully`, }); - // Close overlay and open edit overlay - //closeOverlay(); - if (!isEditing) { closeOverlay();