From e36f241dbad6bc3d08ffe7d385494aef036f9103 Mon Sep 17 00:00:00 2001 From: zetavg Date: Fri, 8 Dec 2023 21:29:44 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=9CCopy=20from=20Container=E2=80=9D=20for?= =?UTF-8?q?=20item=5Freference=5Fnumber?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inventory/screens/SaveItemScreen.tsx | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/App/app/features/inventory/screens/SaveItemScreen.tsx b/App/app/features/inventory/screens/SaveItemScreen.tsx index cd4ab3c0..cc3143ee 100644 --- a/App/app/features/inventory/screens/SaveItemScreen.tsx +++ b/App/app/features/inventory/screens/SaveItemScreen.tsx @@ -218,13 +218,12 @@ function SaveItemScreen({ setReferenceNumberIsRandomlyGenerated(true); }, [itemReferenceDigits]); const copyReferenceNumberFromContainer = useCallback(() => { - // if (typeof selectedContainerData !== 'object') return; - // const itemReferenceNumber = - // selectedContainerData?.itemReferenceNumber; - // if (!itemReferenceNumber) return; - // setData(d => ({ ...d, itemReferenceNumber })); - // setReferenceNumberIsRandomlyGenerated(true); - }, []); + if (typeof selectedContainer !== 'object') return; + const item_reference_number = selectedContainer?.item_reference_number; + if (typeof item_reference_number !== 'string') return; + setData(d => ({ ...d, item_reference_number })); + setReferenceNumberIsRandomlyGenerated(true); + }, [selectedContainer]); const handleOpenSelectIcon = useCallback( () => @@ -951,13 +950,33 @@ function SaveItemScreen({ }} controlElement={ (!data.item_reference_number || - referenceNumberIsRandomlyGenerated) && ( + referenceNumberIsRandomlyGenerated) && + (typeof selectedContainer?.item_reference_number === 'string' && + !data.item_reference_number ? ( + + {({ textProps }) => ( + + Copy from Container + + )} + + ) : ( Generate - ) + )) } {...kiaTextInputProps} />