2.4 KiB
2.4 KiB
🔧 Solución: No se ven los datos
Problema: Los datos no aparecen en el Dashboard o Biblioteca de Contenido
✅ SOLUCIONES APLICADAS
1. Corregido formato de estadísticas
Problema: El hook useContentStats esperaba un formato diferente al que devolvía el backend.
Solución:
- ✅ Backend ahora devuelve campos directos:
protocols,protocolsPublished,guides, etc. - ✅ Hook actualizado para usar estos campos directamente
- ✅ Backend calcula conteos publicados por tipo
2. Verificación de endpoints
Endpoints a verificar:
GET /api/stats/content- Estadísticas de contenidoGET /api/content- Lista de contenidoGET /api/stats/validation- Estadísticas de validación
🔍 VERIFICACIÓN
Verificar Backend
curl http://localhost:3000/health
Verificar Estadísticas
TOKEN=$(curl -s -X POST http://localhost:3000/api/auth/login \
-H 'Content-Type: application/json' \
-d '{"email":"admin@emerges-tes.local","password":"Admin123!"}' \
| python3 -c "import sys, json; print(json.load(sys.stdin)['token'])")
curl http://localhost:3000/api/stats/content \
-H "Authorization: Bearer $TOKEN"
Verificar Contenido
curl "http://localhost:3000/api/content?page=1&pageSize=5" \
-H "Authorization: Bearer $TOKEN"
🛠️ PASOS PARA RESOLVER
-
Verificar que el backend esté corriendo:
lsof -ti :3000 -
Reiniciar backend si es necesario:
cd backend lsof -ti :3000 | xargs kill -9 npm start -
Verificar autenticación:
- Asegurarse de estar logueado en el admin panel
- Verificar que el token esté en localStorage
-
Revisar consola del navegador:
- Abrir DevTools (F12)
- Ver pestaña "Console" para errores
- Ver pestaña "Network" para verificar llamadas API
-
Limpiar caché:
- Ctrl+Shift+R (o Cmd+Shift+R en Mac)
- O limpiar localStorage y volver a loguearse
📊 FORMATO DE DATOS
Estadísticas (GET /api/stats/content)
{
"total": 23,
"protocols": 5,
"protocolsPublished": 5,
"guides": 9,
"guidesPublished": 9,
"drugs": 6,
"drugsPublished": 6,
"checklists": 3,
"checklistsPublished": 3,
"byType": {...},
"byStatus": {...}
}
Contenido (GET /api/content)
{
"items": [...],
"total": 23,
"page": 1,
"pageSize": 20
}
✅ Problema resuelto: Backend devuelve datos en formato correcto