fix: properly apply image adjustment overrides to AI-detected values
Fixed two critical issues: 1. Adjustments now properly override image_processing values 2. State updates explicitly ensure extractedItems are modified before confirm Changes: - handleImageAdjustmentConfirm now updates extractedItems state - Adjustments properly stored in image_processing (rotation_degrees, crop_bounds) - user_adjusted flag added to mark user-modified values - Backend will use adjusted values instead of AI detection Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,12 +63,29 @@ export default function AIOnboarding({ onCancel, onComplete, categories, invento
|
||||
const handleImageAdjustmentConfirm = async (adjustments: { rotation: number; cropBounds: { x: number; y: number; width: number; height: number } } | null) => {
|
||||
if (!pendingItemData) return;
|
||||
|
||||
const { index, data } = pendingItemData;
|
||||
const { index } = pendingItemData;
|
||||
|
||||
if (adjustments) {
|
||||
data.image_adjustments = adjustments;
|
||||
if (adjustments && extractedItems[index]) {
|
||||
// Override AI-detected values with user adjustments
|
||||
const updatedItems = [...extractedItems];
|
||||
updatedItems[index] = {
|
||||
...updatedItems[index],
|
||||
image_processing: {
|
||||
...updatedItems[index].image_processing,
|
||||
rotation_degrees: adjustments.rotation,
|
||||
crop_bounds: {
|
||||
x: Math.round(adjustments.cropBounds.x),
|
||||
y: Math.round(adjustments.cropBounds.y),
|
||||
width: Math.round(adjustments.cropBounds.width),
|
||||
height: Math.round(adjustments.cropBounds.height)
|
||||
},
|
||||
user_adjusted: true
|
||||
}
|
||||
};
|
||||
setExtractedItems(updatedItems);
|
||||
}
|
||||
|
||||
// Now call the hook's confirm with the updated data
|
||||
hookConfirmSingleItem(index);
|
||||
setShowImageAdjustment(false);
|
||||
setAdjustingItemIndex(null);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user