fix: use processed image blob from modal for backend submission
Critical fix: modal processes image and returns blob, but AIOnboarding was not actually using that blob. Now properly calls setExtractedImageBlob() so confirmSingleItem sends the processed image to backend. Before: Backend received original image, applied original AI crop/rotation After: Backend receives processed image (already cropped/rotated by user) Now the saved image matches exactly what user sees after adjusting. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,8 @@ export default function AIOnboarding({ onCancel, onComplete, categories, invento
|
||||
fileInputRef,
|
||||
existingTypes,
|
||||
existingBoxes,
|
||||
extractedImageBlob,
|
||||
setExtractedImageBlob,
|
||||
startLiveCamera,
|
||||
stopLiveCamera,
|
||||
captureSnapshot,
|
||||
@@ -81,27 +83,17 @@ export default function AIOnboarding({ onCancel, onComplete, categories, invento
|
||||
user_adjusted: true
|
||||
}
|
||||
};
|
||||
setExtractedItems(updatedItems);
|
||||
|
||||
// If modal processed and returned image blob, use that instead of original
|
||||
// If modal processed and returned image blob, update the hook's state
|
||||
// so confirmSingleItem uses the processed blob instead of original
|
||||
if (adjustments.imageBlob) {
|
||||
// Convert blob to base64 for extracted_image_bytes
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
const base64 = (reader.result as string).split(',')[1];
|
||||
updatedItems[index].extractedImageBlob = adjustments.imageBlob;
|
||||
updatedItems[index]._base64ImageData = base64;
|
||||
setExtractedItems(updatedItems);
|
||||
hookConfirmSingleItem(index);
|
||||
};
|
||||
reader.readAsDataURL(adjustments.imageBlob);
|
||||
} else {
|
||||
setExtractedItems(updatedItems);
|
||||
hookConfirmSingleItem(index);
|
||||
setExtractedImageBlob(adjustments.imageBlob);
|
||||
}
|
||||
} else {
|
||||
hookConfirmSingleItem(index);
|
||||
}
|
||||
|
||||
// Always call confirm, even without adjustments
|
||||
hookConfirmSingleItem(index);
|
||||
setShowImageAdjustment(false);
|
||||
setAdjustingItemIndex(null);
|
||||
setPendingItemData(null);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user