From 612c7b5a72e0d7186c7582db2d0ef7ef06b53624 Mon Sep 17 00:00:00 2001 From: dwindown Date: Thu, 13 Nov 2025 00:37:46 +0700 Subject: [PATCH] debug: Add extensive logging to find API response structure ## Issue: Endless loading - React Query says query returns undefined ## Debug Logging Added: - Log full API response - Log response.data - Log response type - Check if response has template fields directly - Check if response.data has template fields - Return appropriate data structure This will show us exactly what the API returns so we can fix it properly. Refresh page and check console! --- .../Settings/Notifications/EditTemplate.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx b/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx index 7a9f63c..ef3609e 100644 --- a/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx +++ b/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx @@ -43,7 +43,24 @@ export default function EditTemplate() { console.log('Fetching template for:', eventId, channelId); const response = await api.get(`/notifications/templates/${eventId}/${channelId}`); console.log('API Response:', response); - return response.data; + console.log('API Response.data:', response.data); + console.log('API Response type:', typeof response); + + // The api.get might already unwrap response.data + // Return the response directly if it has the template fields + if (response && (response.subject !== undefined || response.body !== undefined)) { + console.log('Returning response directly:', response); + return response; + } + + // Otherwise return response.data + if (response && response.data) { + console.log('Returning response.data:', response.data); + return response.data; + } + + console.error('No valid template data found in response'); + return null; }, enabled: !!eventId && !!channelId, });