fix: save dominant color from image upload to item record
ImageUpload was discarding the dominantColor returned by the upload API. Now it passes the color through onChange and the item detail page saves it to the item record immediately after upload. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ef531f79b2
commit
fe5bd49b75
2 files changed
+15
-6
No files matched your search
@@ -7,7 +7,7 @@ interface ImageUploadProps {
|
||||
value: string | null;
|
||||
imageUrl?: string | null;
|
||||
dominantColor?: string | null;
|
||||
onChange: (filename: string | null) => void;
|
||||
onChange: (filename: string | null, dominantColor?: string | null) => void;
|
||||
onCropChange?: (crop: { zoom: number; x: number; y: number }) => void;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,11 @@ export function ImageUpload({
|
||||
|
||||
setUploading(true);
|
||||
try {
|
||||
const result = await apiUpload<{ filename: string }>("/api/images", file);
|
||||
onChange(result.filename);
|
||||
const result = await apiUpload<{
|
||||
filename: string;
|
||||
dominantColor?: string | null;
|
||||
}>("/api/images", file);
|
||||
onChange(result.filename, result.dominantColor);
|
||||
if (onCropChange) {
|
||||
setShowCropEditor(true);
|
||||
}
|
||||
|
||||
@@ -274,9 +274,15 @@ function ItemDetail() {
|
||||
value={form.imageFilename}
|
||||
imageUrl={imageUrl}
|
||||
dominantColor={item.dominantColor}
|
||||
onChange={(filename) =>
|
||||
setForm((f) => ({ ...f, imageFilename: filename }))
|
||||
}
|
||||
onChange={(filename, dominantColor) => {
|
||||
setForm((f) => ({ ...f, imageFilename: filename }));
|
||||
if (dominantColor) {
|
||||
updateItem.mutate({
|
||||
id: item.id,
|
||||
dominantColor,
|
||||
});
|
||||
}
|
||||
}}
|
||||
onCropChange={(crop) => {
|
||||
updateItem.mutate({
|
||||
id: item.id,
|
||||
|
||||
Reference in new issue
Block a user