Compare commits
2 Commits
feature/do
...
feature/is
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50a0bd9417 | ||
| 097f0f9cee |
@@ -2,25 +2,64 @@
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-900 mb-6">Scan Item</h1>
|
||||
|
||||
<UCard>
|
||||
<div class="text-center py-12">
|
||||
<UIcon
|
||||
name="i-heroicons-qr-code"
|
||||
class="w-16 h-16 text-gray-400 mx-auto mb-4"
|
||||
<UCard v-if="!scannedBarcode" class="mb-6">
|
||||
<ScanBarcodeScanner
|
||||
@barcode-detected="handleBarcodeDetected"
|
||||
@manual-entry="showManualEntry = true"
|
||||
/>
|
||||
</UCard>
|
||||
|
||||
<!-- Product Lookup Result -->
|
||||
<UCard v-if="productData" class="mb-6">
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-start gap-4">
|
||||
<img
|
||||
v-if="productData.image_url"
|
||||
:src="productData.image_url"
|
||||
:alt="productData.name"
|
||||
class="w-24 h-24 object-cover rounded"
|
||||
/>
|
||||
<div class="flex-1">
|
||||
<h3 class="text-xl font-bold mb-1">{{ productData.name }}</h3>
|
||||
<p v-if="productData.brand" class="text-gray-600">{{ productData.brand }}</p>
|
||||
<p class="text-sm text-gray-500 mt-2">Barcode: {{ scannedBarcode }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<UAlert
|
||||
v-if="lookupError"
|
||||
color="yellow"
|
||||
icon="i-heroicons-exclamation-triangle"
|
||||
title="Product not found"
|
||||
:description="lookupError"
|
||||
/>
|
||||
<h3 class="text-lg font-semibold text-gray-900 mb-2">
|
||||
Barcode Scanner
|
||||
</h3>
|
||||
<p class="text-gray-600 mb-6">
|
||||
This feature will be implemented in Week 3.
|
||||
</p>
|
||||
<UButton
|
||||
to="/"
|
||||
color="gray"
|
||||
variant="soft"
|
||||
>
|
||||
Back to Inventory
|
||||
</UButton>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<UButton
|
||||
color="primary"
|
||||
size="lg"
|
||||
icon="i-heroicons-plus"
|
||||
class="flex-1"
|
||||
@click="addToInventory"
|
||||
>
|
||||
Add to Inventory
|
||||
</UButton>
|
||||
<UButton
|
||||
color="gray"
|
||||
size="lg"
|
||||
@click="resetScanner"
|
||||
>
|
||||
Scan Again
|
||||
</UButton>
|
||||
</div>
|
||||
</div>
|
||||
</UCard>
|
||||
|
||||
<!-- Loading State -->
|
||||
<UCard v-if="isLookingUp">
|
||||
<div class="text-center py-8">
|
||||
<div class="inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-primary-500 mb-4"></div>
|
||||
<p class="text-gray-600">Looking up product...</p>
|
||||
</div>
|
||||
</UCard>
|
||||
</div>
|
||||
@@ -30,4 +69,60 @@
|
||||
definePageMeta({
|
||||
layout: 'default'
|
||||
})
|
||||
|
||||
const scannedBarcode = ref<string | null>(null)
|
||||
const productData = ref<any>(null)
|
||||
const isLookingUp = ref(false)
|
||||
const lookupError = ref<string | null>(null)
|
||||
const showManualEntry = ref(false)
|
||||
|
||||
const handleBarcodeDetected = async (barcode: string) => {
|
||||
scannedBarcode.value = barcode
|
||||
lookupError.value = null
|
||||
isLookingUp.value = true
|
||||
|
||||
try {
|
||||
// TODO: Implement product lookup via Edge Function (Issue #24)
|
||||
// For now, create a basic product object
|
||||
await new Promise(resolve => setTimeout(resolve, 1000)) // Simulate API call
|
||||
|
||||
productData.value = {
|
||||
name: `Product ${barcode}`,
|
||||
brand: 'Unknown Brand',
|
||||
barcode: barcode,
|
||||
image_url: null
|
||||
}
|
||||
|
||||
lookupError.value = 'Product lookup not yet implemented. Using default data.'
|
||||
} catch (error) {
|
||||
console.error('Product lookup error:', error)
|
||||
lookupError.value = 'Failed to look up product. You can still add it manually.'
|
||||
productData.value = {
|
||||
name: `Product ${barcode}`,
|
||||
barcode: barcode
|
||||
}
|
||||
} finally {
|
||||
isLookingUp.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const addToInventory = () => {
|
||||
// TODO: Implement scan-to-add flow (Issue #25)
|
||||
// Navigate to add form with pre-filled data
|
||||
navigateTo({
|
||||
path: '/',
|
||||
query: {
|
||||
barcode: scannedBarcode.value,
|
||||
name: productData.value?.name,
|
||||
brand: productData.value?.brand
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const resetScanner = () => {
|
||||
scannedBarcode.value = null
|
||||
productData.value = null
|
||||
lookupError.value = null
|
||||
isLookingUp.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user