feat: add image confirmation step to AI extraction flow
Users now see the extracted photo during item editing and can choose to: - 'Use Photo': Auto-save the image with the item - 'Skip Photo': Create item without saving the photo Changes: 1. frontend/components/AIOnboarding.tsx: Added image preview panel in edit form - Shows extracted image to user - Buttons to accept/reject photo - Visual feedback when photo is skipped 2. frontend/hooks/useAIExtraction.ts: Updated confirmSingleItem and confirmAllItems - Respect user's photo decision (_skipPhoto flag) - Only pass extractedImageBlob if user approved it - Prevents unwanted auto-photo-save This gives users full control over which extracted photos are auto-saved.
This commit is contained in:
@@ -133,6 +133,8 @@ export function useAIExtraction(inventory: Item[], onComplete: (itemData: any) =
|
||||
|
||||
const confirmSingleItem = (index: number) => {
|
||||
const data = extractedItems[index];
|
||||
const skipPhoto = data._skipPhoto === true; // User explicitly rejected the photo
|
||||
|
||||
const newItem = {
|
||||
name: String(data.Item || data.name || "New AI Item"),
|
||||
category: String(data.Category || data.category || "Uncategorized"),
|
||||
@@ -149,9 +151,11 @@ export function useAIExtraction(inventory: Item[], onComplete: (itemData: any) =
|
||||
min_quantity: 1.0,
|
||||
box_label: data.box_label ? String(data.box_label) : null,
|
||||
labels_data: JSON.stringify(data),
|
||||
// Pass extracted image blob and image_processing metadata for auto-photo-save
|
||||
extractedImageBlob,
|
||||
imageProcessing: data.image_processing
|
||||
// Only pass image blob if user approved it
|
||||
...(skipPhoto ? {} : {
|
||||
extractedImageBlob,
|
||||
imageProcessing: data.image_processing
|
||||
})
|
||||
};
|
||||
onComplete(newItem);
|
||||
|
||||
@@ -174,6 +178,8 @@ export function useAIExtraction(inventory: Item[], onComplete: (itemData: any) =
|
||||
try {
|
||||
for (let i = 0; i < itemsToProcess.length; i++) {
|
||||
const data = itemsToProcess[i];
|
||||
const skipPhoto = data._skipPhoto === true;
|
||||
|
||||
const newItem = {
|
||||
name: String(data.Item || data.name || "New AI Item"),
|
||||
category: String(data.Category || data.category || "Uncategorized"),
|
||||
@@ -190,9 +196,11 @@ export function useAIExtraction(inventory: Item[], onComplete: (itemData: any) =
|
||||
min_quantity: 1.0,
|
||||
box_label: data.box_label ? String(data.box_label) : null,
|
||||
labels_data: JSON.stringify(data),
|
||||
// Pass extracted image blob and image_processing metadata for auto-photo-save
|
||||
extractedImageBlob,
|
||||
imageProcessing: data.image_processing
|
||||
// Only pass image blob if user approved it
|
||||
...(skipPhoto ? {} : {
|
||||
extractedImageBlob,
|
||||
imageProcessing: data.image_processing
|
||||
})
|
||||
};
|
||||
await onComplete(newItem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user