Merge branch 'main' into codex/add-confirmation-prompt-for-pick-list-deletion

This commit is contained in:
beatz174-bit
2025-11-23 13:04:25 +10:00
committed by GitHub
2 changed files with 33 additions and 11 deletions
+20 -11
View File
@@ -19,6 +19,7 @@ interface PickItemRowProps {
item: PickItem; item: PickItem;
product?: Product | null; product?: Product | null;
onIncrementQuantity: () => void; onIncrementQuantity: () => void;
onDecrementQuantity: () => void;
onToggleCarton: () => void; onToggleCarton: () => void;
onStatusChange: (status: PickItem['status']) => void; onStatusChange: (status: PickItem['status']) => void;
onDelete: () => void; onDelete: () => void;
@@ -28,6 +29,7 @@ export const PickItemRow = ({
item, item,
product, product,
onIncrementQuantity, onIncrementQuantity,
onDecrementQuantity,
onToggleCarton, onToggleCarton,
onStatusChange, onStatusChange,
onDelete, onDelete,
@@ -72,21 +74,28 @@ export const PickItemRow = ({
</Stack> </Stack>
<Stack direction="row" spacing={1} alignItems="center"> <Stack direction="row" spacing={1} alignItems="center">
<Button <IconButton
variant={item.is_carton ? 'contained' : 'outlined'} aria-label={`Toggle packaging type (currently ${item.is_carton ? 'carton' : 'unit'})`}
size="small" color={item.is_carton ? 'primary' : 'default'}
onClick={onToggleCarton} onClick={onToggleCarton}
> >
{item.is_carton ? 'Carton' : 'Unit'} <SwapHoriz />
</Button> </IconButton>
<Button variant="contained" size="small" startIcon={<Add />} onClick={onIncrementQuantity}>
Add 1
</Button>
<IconButton <IconButton
color="error" aria-label="Decrease quantity"
onClick={() => setIsConfirmOpen(true)} color="primary"
aria-label={`Delete ${product?.name ?? 'item'}`} onClick={onDecrementQuantity}
> >
<Remove />
</IconButton>
<IconButton
aria-label="Increase quantity"
color="primary"
onClick={onIncrementQuantity}
>
<Add />
</IconButton>
<IconButton color="error" onClick={onDelete} aria-label="Delete item">
<Delete /> <Delete />
</IconButton> </IconButton>
</Stack> </Stack>
+13
View File
@@ -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 handleToggleCarton = async (itemId: string) => {
const existing = await db.pickItems.get(itemId); const existing = await db.pickItems.get(itemId);
if (!existing) return; if (!existing) return;
@@ -73,6 +85,7 @@ export const ActivePickListScreen = () => {
item={item} item={item}
product={products.find((p) => p.id === item.product_id)} product={products.find((p) => p.id === item.product_id)}
onIncrementQuantity={() => handleIncrementQuantity(item.id)} onIncrementQuantity={() => handleIncrementQuantity(item.id)}
onDecrementQuantity={() => handleDecrementQuantity(item.id)}
onToggleCarton={() => handleToggleCarton(item.id)} onToggleCarton={() => handleToggleCarton(item.id)}
onStatusChange={(status) => handleStatusChange(item.id, status)} onStatusChange={(status) => handleStatusChange(item.id, status)}
onDelete={() => handleDeleteItem(item.id)} onDelete={() => handleDeleteItem(item.id)}