From 0a020a668179b2cba3bc0efcc0921dc762ea3463 Mon Sep 17 00:00:00 2001 From: Pantry Lead Agent Date: Wed, 25 Feb 2026 01:26:12 +0000 Subject: [PATCH] feat: add Consume and Restock quick action buttons (#64 #65) --- app/components/inventory/InventoryCard.vue | 145 ++++++++++++++++++--- 1 file changed, 124 insertions(+), 21 deletions(-) diff --git a/app/components/inventory/InventoryCard.vue b/app/components/inventory/InventoryCard.vue index b63fbd1..b520016 100644 --- a/app/components/inventory/InventoryCard.vue +++ b/app/components/inventory/InventoryCard.vue @@ -88,28 +88,106 @@ + + + + + + +
+
+ Current: {{ item.quantity }} {{ item.unit?.abbreviation }} +
+ + + + + +
+ New total: {{ (Number(item.quantity) + Number(restockAmount)).toFixed(2) }} {{ item.unit?.abbreviation }} +
+
+ + +
+
@@ -118,12 +196,17 @@ const props = defineProps<{ item: any }>() -defineEmits<{ +const emit = defineEmits<{ edit: [item: any] delete: [id: string] 'update-quantity': [id: string, change: number] + 'consume': [id: string] + 'restock': [id: string, amount: number] }>() +const showRestockModal = ref(false) +const restockAmount = ref(1) + // Calculate days until expiry const daysUntilExpiry = computed(() => { if (!props.item.expiry_date) return null @@ -163,4 +246,24 @@ const isLowStock = computed(() => { if (!props.item.low_stock_threshold) return false return Number(props.item.quantity) <= Number(props.item.low_stock_threshold) }) + +// Quick actions +const handleConsume = () => { + emit('update-quantity', props.item.id, -1) +} + +const handleRestock = () => { + if (restockAmount.value && restockAmount.value > 0) { + emit('update-quantity', props.item.id, restockAmount.value) + showRestockModal.value = false + restockAmount.value = 1 // Reset for next time + } +} + +// Reset restock amount when modal closes +watch(showRestockModal, (isOpen) => { + if (!isOpen) { + restockAmount.value = 1 + } +})