diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 6a1f958..d46a9fa 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -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'); } diff --git a/src/app/api/admin/images/route.ts b/src/app/api/admin/images/route.ts index baf2211..273efdc 100644 --- a/src/app/api/admin/images/route.ts +++ b/src/app/api/admin/images/route.ts @@ -53,7 +53,7 @@ export async function POST(request: NextRequest) { [filename, data, category || 'other', room_id || null, location_target || 'gallery'] ); - return NextResponse.json({ image: rows[0] }); + return NextResponse.json({ data: rows[0] }); } catch (error) { if ((error as Error).message === 'Unauthorized') { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });