fix: image upload returns correct data structure for all editors
This commit is contained in:
@@ -744,7 +744,7 @@ function SocialEditor({ event, setEvent, images, onSave, onCancel }: any) {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ filename: f.name, data: b64, category: 'social', room_id: null, location_target: 'social' }),
|
||||
});
|
||||
if (r.ok) { const d = await r.json(); newPhotos.push(d.data); }
|
||||
if (r.ok) { const d = await r.json(); newPhotos.push(d.data.data); }
|
||||
} catch { const b = await readFileBase64(f); newPhotos.push(b); }
|
||||
}
|
||||
setLocalPhotos(prev => [...prev, ...newPhotos]);
|
||||
@@ -856,7 +856,7 @@ function RoomEditor({ room, setRoom, images, onSave, onCancel }: any) {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ filename: f.name, data: b64, category: 'rooms', room_id: r.id || null, location_target: `room-${r.id || 'new'}` }),
|
||||
});
|
||||
if (res.ok) { const d = await res.json(); newPhotos.push(d.data); }
|
||||
if (res.ok) { const d = await res.json(); newPhotos.push(d.data.data); }
|
||||
} catch { const b = await readFileBase64(f); newPhotos.push(b); }
|
||||
}
|
||||
setLocalPhotos(prev => [...prev, ...newPhotos]);
|
||||
@@ -1192,7 +1192,7 @@ function PlaceEditor({ place, setPlace, images, onSave, onCancel }: any) {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ filename: f.name, data: b64, category: 'landscape', room_id: null, location_target: `place-${p.id || 'new'}` }),
|
||||
});
|
||||
if (res.ok) { const d = await res.json(); newPhotos.push(d.data); }
|
||||
if (res.ok) { const d = await res.json(); newPhotos.push(d.data.data); }
|
||||
} catch { const b = await readFileBase64(f); newPhotos.push(b); }
|
||||
}
|
||||
setLocalPhotos(prev => [...prev, ...newPhotos]);
|
||||
@@ -1310,7 +1310,7 @@ function BrandSection({ images, onToast }: { images: Image[]; onToast: (m: strin
|
||||
});
|
||||
if (res.ok) {
|
||||
const d = await res.json();
|
||||
setConfig(prev => ({ ...prev, [key]: d.data }));
|
||||
setConfig(prev => ({ ...prev, [key]: d.data.data }));
|
||||
onToast('Image uploaded!', 'success');
|
||||
}
|
||||
} catch { onToast('Upload failed', 'error'); }
|
||||
|
||||
Reference in New Issue
Block a user