From 50a0bd9417f7cfa816ab327ada34f22fc4289152 Mon Sep 17 00:00:00 2001 From: Pantry Lead Agent Date: Tue, 24 Feb 2026 00:01:49 +0000 Subject: [PATCH] feat: integrate BarcodeScanner into scan page (#22 #23) - Use ScanBarcodeScanner component in scan.vue - Add product lookup placeholder (Issue #24) - Add scan-to-add flow placeholder (Issue #25) - Handle barcode detection events - Show loading and error states - Allow rescan and manual entry Closes #22, #23 --- app/pages/scan.vue | 131 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 113 insertions(+), 18 deletions(-) diff --git a/app/pages/scan.vue b/app/pages/scan.vue index 6346fbb..ae0f8b1 100644 --- a/app/pages/scan.vue +++ b/app/pages/scan.vue @@ -2,25 +2,64 @@

Scan Item

- -
- + + + + + +
+
+ +
+

{{ productData.name }}

+

{{ productData.brand }}

+

Barcode: {{ scannedBarcode }}

+
+
+ + -

- Barcode Scanner -

-

- This feature will be implemented in Week 3. -

- - Back to Inventory - + +
+ + Add to Inventory + + + Scan Again + +
+
+
+ + + +
+
+

Looking up product...

@@ -30,4 +69,60 @@ definePageMeta({ layout: 'default' }) + +const scannedBarcode = ref(null) +const productData = ref(null) +const isLookingUp = ref(false) +const lookupError = ref(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 +} -- 2.49.1