fix: admin data loading - extract data from API response
This commit is contained in:
@@ -1731,14 +1731,14 @@ export default function AdminPage() {
|
|||||||
fetch('/api/reviews'),
|
fetch('/api/reviews'),
|
||||||
fetch('/api/admin/images').catch(() => null),
|
fetch('/api/admin/images').catch(() => null),
|
||||||
]);
|
]);
|
||||||
if (slidesRes.ok) { const d = await slidesRes.json(); setSlides(Array.isArray(d) ? d : []); }
|
if (slidesRes.ok) { const d = await slidesRes.json(); setSlides(Array.isArray(d) ? d : (d.data || [])); }
|
||||||
if (roomsRes.ok) { const d = await roomsRes.json(); setRooms(Array.isArray(d) ? d : []); }
|
if (roomsRes.ok) { const d = await roomsRes.json(); setRooms(Array.isArray(d) ? d : (d.data || [])); }
|
||||||
if (calRes.ok) { const d = await calRes.json(); setEvents(Array.isArray(d) ? d : []); }
|
if (calRes.ok) { const d = await calRes.json(); setEvents(Array.isArray(d) ? d : (d.data || [])); }
|
||||||
if (socialRes.ok) { const d = await socialRes.json(); setSocialEvents(Array.isArray(d) ? d : []); }
|
if (socialRes.ok) { const d = await socialRes.json(); setSocialEvents(Array.isArray(d) ? d : (d.data || [])); }
|
||||||
if (menuRes.ok) { const d = await menuRes.json(); setMenuItems(Array.isArray(d) ? d : (d.data || [])); }
|
if (menuRes.ok) { const d = await menuRes.json(); setMenuItems(Array.isArray(d) ? d : (d.data || [])); }
|
||||||
if (placesRes.ok) { const d = await placesRes.json(); setPlaces(Array.isArray(d) ? d : []); }
|
if (placesRes.ok) { const d = await placesRes.json(); setPlaces(Array.isArray(d) ? d : (d.data || [])); }
|
||||||
if (reviewsRes.ok) { const d = await reviewsRes.json(); setReviews(Array.isArray(d) ? d : []); }
|
if (reviewsRes.ok) { const d = await reviewsRes.json(); setReviews(Array.isArray(d) ? d : (d.data || [])); }
|
||||||
if (imagesRes?.ok) { const d = await imagesRes.json(); setImages(Array.isArray(d) ? d : (d.images || [])); }
|
if (imagesRes?.ok) { const d = await imagesRes.json(); setImages(Array.isArray(d) ? d : (d.data || d.images || [])); }
|
||||||
} catch (err) { console.error('Failed to load admin data:', err); }
|
} catch (err) { console.error('Failed to load admin data:', err); }
|
||||||
};
|
};
|
||||||
fetchAll();
|
fetchAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user