codigo0/docs/SOLUCION_NO_VE_DATOS.md

115 lines
2.4 KiB
Markdown

# 🔧 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 contenido
- `GET /api/content` - Lista de contenido
- `GET /api/stats/validation` - Estadísticas de validación
---
## 🔍 VERIFICACIÓN
### Verificar Backend
```bash
curl http://localhost:3000/health
```
### Verificar Estadísticas
```bash
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
```bash
curl "http://localhost:3000/api/content?page=1&pageSize=5" \
-H "Authorization: Bearer $TOKEN"
```
---
## 🛠️ PASOS PARA RESOLVER
1. **Verificar que el backend esté corriendo:**
```bash
lsof -ti :3000
```
2. **Reiniciar backend si es necesario:**
```bash
cd backend
lsof -ti :3000 | xargs kill -9
npm start
```
3. **Verificar autenticación:**
- Asegurarse de estar logueado en el admin panel
- Verificar que el token esté en localStorage
4. **Revisar consola del navegador:**
- Abrir DevTools (F12)
- Ver pestaña "Console" para errores
- Ver pestaña "Network" para verificar llamadas API
5. **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)
```json
{
"total": 23,
"protocols": 5,
"protocolsPublished": 5,
"guides": 9,
"guidesPublished": 9,
"drugs": 6,
"drugsPublished": 6,
"checklists": 3,
"checklistsPublished": 3,
"byType": {...},
"byStatus": {...}
}
```
### Contenido (GET /api/content)
```json
{
"items": [...],
"total": 23,
"page": 1,
"pageSize": 20
}
```
---
**✅ Problema resuelto: Backend devuelve datos en formato correcto**