diff --git a/src/components/PickItemRow.tsx b/src/components/PickItemRow.tsx index f1974bb..6c01516 100644 --- a/src/components/PickItemRow.tsx +++ b/src/components/PickItemRow.tsx @@ -19,6 +19,7 @@ interface PickItemRowProps { item: PickItem; product?: Product | null; onIncrementQuantity: () => void; + onDecrementQuantity: () => void; onToggleCarton: () => void; onStatusChange: (status: PickItem['status']) => void; onDelete: () => void; @@ -28,6 +29,7 @@ export const PickItemRow = ({ item, product, onIncrementQuantity, + onDecrementQuantity, onToggleCarton, onStatusChange, onDelete, @@ -72,21 +74,28 @@ export const PickItemRow = ({ - - + + setIsConfirmOpen(true)} - aria-label={`Delete ${product?.name ?? 'item'}`} + aria-label="Decrease quantity" + color="primary" + onClick={onDecrementQuantity} > + + + + + + diff --git a/src/screens/ActivePickListScreen.tsx b/src/screens/ActivePickListScreen.tsx index 4c41850..ecc461e 100644 --- a/src/screens/ActivePickListScreen.tsx +++ b/src/screens/ActivePickListScreen.tsx @@ -29,6 +29,18 @@ export const ActivePickListScreen = () => { }); }; + const handleDecrementQuantity = async (itemId: string) => { + const existing = await db.pickItems.get(itemId); + if (!existing) return; + + const nextQuantity = Math.max(1, (existing.quantity || 1) - 1); + + await db.pickItems.update(itemId, { + quantity: nextQuantity, + updated_at: Date.now(), + }); + }; + const handleToggleCarton = async (itemId: string) => { const existing = await db.pickItems.get(itemId); if (!existing) return; @@ -73,6 +85,7 @@ export const ActivePickListScreen = () => { item={item} product={products.find((p) => p.id === item.product_id)} onIncrementQuantity={() => handleIncrementQuantity(item.id)} + onDecrementQuantity={() => handleDecrementQuantity(item.id)} onToggleCarton={() => handleToggleCarton(item.id)} onStatusChange={(status) => handleStatusChange(item.id, status)} onDelete={() => handleDeleteItem(item.id)}