Compare commits

...

7 Commits

Author SHA1 Message Date
Pantry Lead Agent
bf4d365357 feat: integrate ExpiryDashboard into inventory page (#69)
Some checks failed
Deploy to Coolify / Code Quality (pull_request) Has been cancelled
Deploy to Coolify / Run Tests (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Development (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Production (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Test (pull_request) Has been cancelled
Pull Request Checks / Validate PR (pull_request) Has been cancelled
2026-02-25 01:27:27 +00:00
Pantry Lead Agent
6eb3169be3 feat: create ExpiryDashboard component (#69) 2026-02-25 01:27:07 +00:00
3209adcf40 Merge pull request 'feat: add Consume and Restock quick actions (#64 #65)' (#72) from feature/issue-64-65-quick-actions into develop
Some checks failed
Deploy to Coolify / Deploy to Development (push) Has been cancelled
Deploy to Coolify / Deploy to Production (push) Has been cancelled
Deploy to Coolify / Deploy to Test (push) Has been cancelled
Deploy to Coolify / Code Quality (push) Has been cancelled
Deploy to Coolify / Run Tests (push) Has been cancelled
2026-02-25 01:26:27 +00:00
Pantry Lead Agent
0a020a6681 feat: add Consume and Restock quick action buttons (#64 #65)
Some checks failed
Deploy to Coolify / Code Quality (pull_request) Has been cancelled
Deploy to Coolify / Run Tests (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Development (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Production (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Test (pull_request) Has been cancelled
Pull Request Checks / Validate PR (pull_request) Has been cancelled
2026-02-25 01:26:12 +00:00
ec6dd68e70 Merge pull request 'feat: add search and filter UI for inventory (#66)' (#71) from feature/issue-66-search-filter into develop
Some checks failed
Deploy to Coolify / Code Quality (push) Has been cancelled
Deploy to Coolify / Run Tests (push) Has been cancelled
Deploy to Coolify / Deploy to Development (push) Has been cancelled
Deploy to Coolify / Deploy to Production (push) Has been cancelled
Deploy to Coolify / Deploy to Test (push) Has been cancelled
2026-02-25 01:25:29 +00:00
Pantry Lead Agent
76c4a875ff feat: implement search filtering in InventoryList (#66)
Some checks failed
Pull Request Checks / Validate PR (pull_request) Has been cancelled
Deploy to Coolify / Code Quality (pull_request) Has been cancelled
Deploy to Coolify / Run Tests (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Development (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Production (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Test (pull_request) Has been cancelled
2026-02-25 01:25:16 +00:00
Pantry Lead Agent
2635483dbc feat: add search bar to inventory page (#66) 2026-02-25 01:25:05 +00:00
4 changed files with 332 additions and 37 deletions

View File

@@ -0,0 +1,130 @@
<template>
<UCard v-if="expiringItems.length > 0">
<template #header>
<div class="flex items-center justify-between">
<div class="flex items-center gap-2">
<UIcon name="i-heroicons-exclamation-triangle" class="w-5 h-5 text-orange-500" />
<h3 class="text-lg font-semibold">Items Expiring Soon</h3>
</div>
<UBadge color="orange" variant="soft">
{{ expiringItems.length }}
</UBadge>
</div>
</template>
<div class="space-y-2">
<div
v-for="item in displayedItems"
:key="item.id"
class="flex items-center justify-between p-3 rounded-lg hover:bg-gray-50 transition-colors"
:class="getItemBgClass(item)"
>
<div class="flex-1 min-w-0">
<p class="font-medium text-gray-900 truncate">{{ item.name }}</p>
<div class="flex items-center gap-2 text-sm">
<UBadge :color="getExpiryColor(item)" size="xs">
{{ getExpiryText(item) }}
</UBadge>
<span class="text-gray-600">
{{ item.quantity }} {{ item.unit?.abbreviation }}
</span>
</div>
</div>
<UButton
size="xs"
color="gray"
variant="ghost"
icon="i-heroicons-arrow-right"
@click="$emit('view-item', item)"
/>
</div>
<UButton
v-if="expiringItems.length > maxDisplay"
color="gray"
variant="soft"
size="sm"
class="w-full"
@click="expanded = !expanded"
>
{{ expanded ? 'Show Less' : `Show ${expiringItems.length - maxDisplay} More` }}
</UButton>
</div>
</UCard>
</template>
<script setup lang="ts">
const props = defineProps<{
items: any[]
maxDisplay?: number
}>()
const emit = defineEmits<{
'view-item': [item: any]
}>()
const expanded = ref(false)
const maxDisplay = props.maxDisplay || 5
// Filter and sort items by expiry
const expiringItems = computed(() => {
const now = new Date()
const thirtyDaysFromNow = new Date()
thirtyDaysFromNow.setDate(now.getDate() + 30)
return props.items
.filter(item => {
if (!item.expiry_date) return false
const expiryDate = new Date(item.expiry_date)
return expiryDate <= thirtyDaysFromNow
})
.sort((a, b) => {
const dateA = new Date(a.expiry_date)
const dateB = new Date(b.expiry_date)
return dateA.getTime() - dateB.getTime()
})
})
const displayedItems = computed(() => {
if (expanded.value) {
return expiringItems.value
}
return expiringItems.value.slice(0, maxDisplay)
})
// Helper functions
const getDaysUntilExpiry = (item: any) => {
if (!item.expiry_date) return null
const today = new Date()
const expiry = new Date(item.expiry_date)
return Math.ceil((expiry.getTime() - today.getTime()) / (1000 * 60 * 60 * 24))
}
const getExpiryColor = (item: any) => {
const days = getDaysUntilExpiry(item)
if (days === null) return 'gray'
if (days < 0) return 'red'
if (days <= 3) return 'orange'
if (days <= 7) return 'yellow'
return 'green'
}
const getExpiryText = (item: any) => {
const days = getDaysUntilExpiry(item)
if (days === null) return 'No expiry'
if (days < 0) return `Expired ${Math.abs(days)}d ago`
if (days === 0) return 'Expires today'
if (days === 1) return 'Expires tomorrow'
if (days <= 7) return `${days} days left`
return `${days} days left`
}
const getItemBgClass = (item: any) => {
const days = getDaysUntilExpiry(item)
if (days === null) return ''
if (days < 0) return 'bg-red-50'
if (days <= 3) return 'bg-orange-50'
return ''
}
</script>

View File

@@ -88,13 +88,37 @@
<!-- Action Buttons --> <!-- Action Buttons -->
<template #footer> <template #footer>
<div class="flex gap-2"> <div class="flex flex-col gap-2">
<!-- Quick Actions Row -->
<div class="grid grid-cols-2 gap-2">
<UButton
icon="i-heroicons-arrow-trending-down"
size="sm"
color="orange"
variant="soft"
@click="handleConsume"
:disabled="item.quantity <= 0.01"
>
Consume
</UButton>
<UButton
icon="i-heroicons-arrow-trending-up"
size="sm"
color="green"
variant="soft"
@click="showRestockModal = true"
>
Restock
</UButton>
</div>
<!-- Management Actions Row -->
<div class="grid grid-cols-2 gap-2">
<UButton <UButton
icon="i-heroicons-pencil" icon="i-heroicons-pencil"
size="sm" size="sm"
color="gray" color="gray"
variant="soft" variant="soft"
class="flex-1"
@click="$emit('edit', item)" @click="$emit('edit', item)"
> >
Edit Edit
@@ -109,7 +133,61 @@
Delete Delete
</UButton> </UButton>
</div> </div>
</div>
</template> </template>
<!-- Restock Modal -->
<UModal v-model="showRestockModal">
<UCard>
<template #header>
<h3 class="text-lg font-semibold">Restock {{ item.name }}</h3>
</template>
<div class="space-y-4">
<div class="text-sm text-gray-600">
Current: <span class="font-semibold">{{ item.quantity }} {{ item.unit?.abbreviation }}</span>
</div>
<UFormGroup label="Amount to add">
<UInput
v-model.number="restockAmount"
type="number"
min="0.01"
step="0.01"
size="lg"
autofocus
placeholder="e.g. 5"
/>
</UFormGroup>
<div v-if="restockAmount > 0" class="text-sm text-gray-600">
New total: <span class="font-semibold">{{ (Number(item.quantity) + Number(restockAmount)).toFixed(2) }} {{ item.unit?.abbreviation }}</span>
</div>
</div>
<template #footer>
<div class="flex gap-2">
<UButton
color="primary"
size="lg"
class="flex-1"
@click="handleRestock"
:disabled="!restockAmount || restockAmount <= 0"
>
Add {{ restockAmount || 0 }} {{ item.unit?.abbreviation }}
</UButton>
<UButton
color="gray"
size="lg"
variant="soft"
@click="showRestockModal = false"
>
Cancel
</UButton>
</div>
</template>
</UCard>
</UModal>
</UCard> </UCard>
</template> </template>
@@ -118,12 +196,17 @@ const props = defineProps<{
item: any item: any
}>() }>()
defineEmits<{ const emit = defineEmits<{
edit: [item: any] edit: [item: any]
delete: [id: string] delete: [id: string]
'update-quantity': [id: string, change: number] 'update-quantity': [id: string, change: number]
'consume': [id: string]
'restock': [id: string, amount: number]
}>() }>()
const showRestockModal = ref(false)
const restockAmount = ref<number>(1)
// Calculate days until expiry // Calculate days until expiry
const daysUntilExpiry = computed(() => { const daysUntilExpiry = computed(() => {
if (!props.item.expiry_date) return null if (!props.item.expiry_date) return null
@@ -163,4 +246,24 @@ const isLowStock = computed(() => {
if (!props.item.low_stock_threshold) return false if (!props.item.low_stock_threshold) return false
return Number(props.item.quantity) <= Number(props.item.low_stock_threshold) 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
}
})
</script> </script>

View File

@@ -60,6 +60,7 @@ const { getInventory, deleteInventoryItem, updateQuantity } = useInventory()
const props = defineProps<{ const props = defineProps<{
refresh?: boolean refresh?: boolean
tagFilters?: string[] tagFilters?: string[]
searchQuery?: string
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
@@ -89,17 +90,27 @@ const loadInventory = async () => {
// Computed filtered items // Computed filtered items
const filteredItems = computed(() => { const filteredItems = computed(() => {
if (!props.tagFilters || props.tagFilters.length === 0) { let result = items.value
return items.value
// Filter by search query (case-insensitive)
if (props.searchQuery && props.searchQuery.trim()) {
const query = props.searchQuery.trim().toLowerCase()
result = result.filter(item =>
item.name.toLowerCase().includes(query)
)
} }
// Filter items that have at least one of the selected tags // Filter by tags
return items.value.filter(item => { if (props.tagFilters && props.tagFilters.length > 0) {
result = result.filter(item => {
if (!item.tags || item.tags.length === 0) return false if (!item.tags || item.tags.length === 0) return false
const itemTagIds = item.tags.map((t: any) => t.tag.id) const itemTagIds = item.tags.map((t: any) => t.tag.id)
return props.tagFilters!.some(filterId => itemTagIds.includes(filterId)) return props.tagFilters!.some(filterId => itemTagIds.includes(filterId))
}) })
}
return result
}) })
const handleDelete = async (id: string) => { const handleDelete = async (id: string) => {

View File

@@ -33,9 +33,36 @@
</div> </div>
</div> </div>
<!-- Search & Filters -->
<UCard v-if="showFilters" class="mb-6 space-y-4">
<!-- Search Bar -->
<div>
<UFormGroup label="Search Items">
<UInput
v-model="searchQuery"
placeholder="Search by item name..."
icon="i-heroicons-magnifying-glass"
size="lg"
:ui="{ icon: { trailing: { pointer: '' } } }"
>
<template #trailing>
<UButton
v-if="searchQuery"
color="gray"
variant="link"
icon="i-heroicons-x-mark"
:padded="false"
@click="searchQuery = ''"
/>
</template>
</UInput>
</UFormGroup>
</div>
<!-- Tag Filters --> <!-- Tag Filters -->
<UCard v-if="showFilters" class="mb-6"> <div>
<TagsTagFilter v-model="selectedTagFilters" /> <TagsTagFilter v-model="selectedTagFilters" />
</div>
</UCard> </UCard>
<!-- Add Item Form (Overlay) --> <!-- Add Item Form (Overlay) -->
@@ -56,11 +83,20 @@
@updated="handleItemUpdated" @updated="handleItemUpdated"
/> />
<!-- Expiry Dashboard -->
<div class="mb-6">
<InventoryExpiryDashboard
:items="inventoryItems"
@view-item="editingItem = $event"
/>
</div>
<!-- Inventory List --> <!-- Inventory List -->
<InventoryList <InventoryList
ref="inventoryListRef" ref="inventoryListRef"
:refresh="refreshKey" :refresh="refreshKey"
:tag-filters="selectedTagFilters" :tag-filters="selectedTagFilters"
:search-query="searchQuery"
@add-item="showAddForm = true" @add-item="showAddForm = true"
@edit-item="editingItem = $event" @edit-item="editingItem = $event"
/> />
@@ -82,9 +118,22 @@ const refreshKey = ref(0)
const inventoryListRef = ref() const inventoryListRef = ref()
const prefilledData = ref<any>(null) const prefilledData = ref<any>(null)
const selectedTagFilters = ref<string[]>([]) const selectedTagFilters = ref<string[]>([])
const searchQuery = ref('')
const inventoryItems = ref<any[]>([])
// Load inventory for dashboard
const { getInventory } = useInventory()
const loadInventoryData = async () => {
const { data } = await getInventory()
inventoryItems.value = data || []
}
// Handle scan-to-add flow (Issue #25) // Handle scan-to-add flow (Issue #25)
onMounted(() => { onMounted(async () => {
// Load inventory for dashboard
await loadInventoryData()
if (route.query.action === 'add') { if (route.query.action === 'add') {
// Pre-fill data from query params (from scan) // Pre-fill data from query params (from scan)
prefilledData.value = { prefilledData.value = {
@@ -107,15 +156,17 @@ const handleCloseAddForm = () => {
prefilledData.value = null prefilledData.value = null
} }
const handleItemAdded = (item: any) => { const handleItemAdded = async (item: any) => {
showAddForm.value = false showAddForm.value = false
prefilledData.value = null prefilledData.value = null
// Reload the inventory list // Reload the inventory list and dashboard
inventoryListRef.value?.reload() inventoryListRef.value?.reload()
await loadInventoryData()
} }
const handleItemUpdated = (item: any) => { const handleItemUpdated = async (item: any) => {
editingItem.value = null editingItem.value = null
inventoryListRef.value?.reload() inventoryListRef.value?.reload()
await loadInventoryData()
} }
</script> </script>