From b28eb49fe7ffdf649c0f0c932c88cd07bcdf1cd1 Mon Sep 17 00:00:00 2001 From: Daniel Bedeleanu Date: Wed, 22 Apr 2026 17:44:11 +0300 Subject: [PATCH] feat(5-plan-02-t3,t4): create useItemSearch hook and integrate search button into inventory page --- frontend/app/inventory/page.tsx | 40 +++++++- frontend/hooks/useItemSearch.ts | 171 ++++++++++++++++++-------------- 2 files changed, 136 insertions(+), 75 deletions(-) diff --git a/frontend/app/inventory/page.tsx b/frontend/app/inventory/page.tsx index e162bf8a..bae11a8e 100644 --- a/frontend/app/inventory/page.tsx +++ b/frontend/app/inventory/page.tsx @@ -8,6 +8,8 @@ import Scanner from '@/components/Scanner'; import StatCard from '@/components/StatCard'; import InventoryTable from '@/components/InventoryTable'; import FilterBar from '@/components/FilterBar'; +import SearchModal from '@/components/inventory/SearchModal'; +import QuantityAdjustmentModal from '@/components/inventory/QuantityAdjustmentModal'; import { useInventoryFilter } from '@/hooks/useInventoryFilter'; import { toast } from 'react-hot-toast'; import { @@ -80,6 +82,11 @@ export default function InventoryPage() { const [showBoxManager, setShowBoxManager] = useState(false); const [selectedBoxLabel, setSelectedBoxLabel] = useState(null); + // Search Modal State + const [showSearchModal, setShowSearchModal] = useState(false); + const [selectedSearchItem, setSelectedSearchItem] = useState(null); + const [showQuantityModal, setShowQuantityModal] = useState(false); + useEffect(() => { setMounted(true); const savedUser = localStorage.getItem('inventory_user'); @@ -238,6 +245,16 @@ export default function InventoryPage() { } }, [inventory]); + const handleSearchItemSelect = (item: Item) => { + setSelectedSearchItem(item); + setShowQuantityModal(true); + }; + + const handleQuantityModalClose = () => { + setShowQuantityModal(false); + setSelectedSearchItem(null); + }; + // Extract unique item types and box labels for suggestions const existingTypes = Array.from(new Set(inventory.map(i => i.type).filter(Boolean))).sort() as string[]; const existingBoxes = Array.from(new Set(inventory.map(i => i.box_label).filter(Boolean))).sort() as string[]; @@ -263,8 +280,15 @@ export default function InventoryPage() {

Enterprise Stock Overview

+