Compare commits

..

4 Commits

Author SHA1 Message Date
c04586f76a Merge pull request 'feat: add low-stock dashboard alerts (#68)' (#74) from feature/issue-68-lowstock-dashboard 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:28:33 +00:00
Pantry Lead Agent
d23644d90f feat: integrate LowStockDashboard into inventory page (#68)
Some checks failed
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 Test (pull_request) Has been cancelled
Pull Request Checks / Validate PR (pull_request) Has been cancelled
Deploy to Coolify / Code Quality (pull_request) Has been cancelled
Deploy to Coolify / Deploy to Production (pull_request) Has been cancelled
2026-02-25 01:28:18 +00:00
Pantry Lead Agent
b29e17998d feat: create LowStockDashboard component (#68) 2026-02-25 01:28:07 +00:00
bbccbd09ed Merge pull request 'feat: add expiry warnings dashboard (#69)' (#73) from feature/issue-69-expiry-dashboard 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:27:41 +00:00
2 changed files with 125 additions and 2 deletions

View File

@@ -0,0 +1,110 @@
<template>
<UCard v-if="lowStockItems.length > 0">
<template #header>
<div class="flex items-center justify-between">
<div class="flex items-center gap-2">
<UIcon name="i-heroicons-arrow-trending-down" class="w-5 h-5 text-orange-500" />
<h3 class="text-lg font-semibold">Low Stock Items</h3>
</div>
<UBadge color="orange" variant="soft">
{{ lowStockItems.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 bg-orange-50 hover:bg-orange-100 transition-colors"
>
<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="orange" size="xs">
{{ item.quantity }}/{{ item.low_stock_threshold }} {{ item.unit?.abbreviation }}
</UBadge>
<span class="text-gray-600">
{{ getUrgencyText(item) }}
</span>
</div>
</div>
<div class="flex gap-1">
<UButton
size="xs"
color="green"
variant="soft"
icon="i-heroicons-arrow-trending-up"
@click="$emit('restock-item', item)"
>
Restock
</UButton>
<UButton
size="xs"
color="gray"
variant="ghost"
icon="i-heroicons-pencil"
@click="$emit('view-item', item)"
/>
</div>
</div>
<UButton
v-if="lowStockItems.length > maxDisplay"
color="gray"
variant="soft"
size="sm"
class="w-full"
@click="expanded = !expanded"
>
{{ expanded ? 'Show Less' : `Show ${lowStockItems.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]
'restock-item': [item: any]
}>()
const expanded = ref(false)
const maxDisplay = props.maxDisplay || 5
// Filter and sort items by low stock urgency
const lowStockItems = computed(() => {
return props.items
.filter(item => {
if (!item.low_stock_threshold) return false
return Number(item.quantity) <= Number(item.low_stock_threshold)
})
.sort((a, b) => {
// Sort by urgency: items closest to 0 first
const urgencyA = Number(a.quantity) / Number(a.low_stock_threshold)
const urgencyB = Number(b.quantity) / Number(b.low_stock_threshold)
return urgencyA - urgencyB
})
})
const displayedItems = computed(() => {
if (expanded.value) {
return lowStockItems.value
}
return lowStockItems.value.slice(0, maxDisplay)
})
// Helper function
const getUrgencyText = (item: any) => {
const ratio = Number(item.quantity) / Number(item.low_stock_threshold)
if (ratio <= 0.25) return 'Critical'
if (ratio <= 0.5) return 'Very low'
return 'Low'
}
</script>

View File

@@ -83,12 +83,20 @@
@updated="handleItemUpdated"
/>
<!-- Expiry Dashboard -->
<div class="mb-6">
<!-- Dashboard Cards -->
<div class="grid gap-6 mb-6 md:grid-cols-2">
<!-- Expiry Dashboard -->
<InventoryExpiryDashboard
:items="inventoryItems"
@view-item="editingItem = $event"
/>
<!-- Low Stock Dashboard -->
<InventoryLowStockDashboard
:items="inventoryItems"
@view-item="editingItem = $event"
@restock-item="handleRestockFromDashboard"
/>
</div>
<!-- Inventory List -->
@@ -169,4 +177,9 @@ const handleItemUpdated = async (item: any) => {
inventoryListRef.value?.reload()
await loadInventoryData()
}
const handleRestockFromDashboard = (item: any) => {
// Open edit modal with the item (user can use Restock button there)
editingItem.value = item
}
</script>