fix: save dominant color from image upload to item record
CI / ci (push) Successful in 1m12s
CI / e2e (push) Has been skipped
CI / deploy (push) Successful in 13s

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:
2026-04-12 23:39:13 +02:00
co-authored by Claude Opus 4.6
parent ef531f79b2
commit fe5bd49b75
2 changed files with 15 additions and 6 deletions
+6 -3
View File
@@ -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);
}
+9 -3
View File
@@ -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,