Se soluciono autenticacion
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { fetchWithAuth } from '../fetchWithAuth';
|
||||
// Animación fade-in/slide-up para cards
|
||||
const fadeInSlideUp = `@keyframes fadein-slideup {
|
||||
0% { opacity: 0; transform: translateY(40px); }
|
||||
@@ -45,33 +46,31 @@ export default function Admin() {
|
||||
setLoading(true);
|
||||
setError('');
|
||||
try {
|
||||
const token = localStorage.getItem('access');
|
||||
const headers = token ? { 'Authorization': `Bearer ${token}` } : {};
|
||||
|
||||
// Servicios
|
||||
const resServices = await fetch(`${API_URL}/cards/services-util-information/`, { headers });
|
||||
const resServices = await fetchWithAuth(`${API_URL}/cards/services-util-information/`);
|
||||
if (!resServices.ok) throw new Error('Error al obtener estados de servicios');
|
||||
const dataServices = await resServices.json();
|
||||
setServices(dataServices);
|
||||
|
||||
// Descargas
|
||||
const resDownloads = await fetch(`${API_URL}/cards/document-util-information/`, { headers });
|
||||
const resDownloads = await fetchWithAuth(`${API_URL}/cards/document-util-information/`);
|
||||
if (!resDownloads.ok) throw new Error('Error al obtener información de descargas');
|
||||
const dataDownloads = await resDownloads.json();
|
||||
setDownloads(dataDownloads);
|
||||
|
||||
// Últimos documentos
|
||||
const resDocs = await fetch(`${API_URL}/cards/downloaded-documents/`, { headers });
|
||||
const resDocs = await fetchWithAuth(`${API_URL}/cards/downloaded-documents/`);
|
||||
if (!resDocs.ok) throw new Error('Error al obtener últimos documentos');
|
||||
const dataDocs = await resDocs.json();
|
||||
setLatestDocs(dataDocs.documentos);
|
||||
|
||||
// Análisis de actividad de usuario
|
||||
const resUserActivity = await fetch(`${API_URL}/cards/user-activity-analysis/`, { headers });
|
||||
const resUserActivity = await fetchWithAuth(`${API_URL}/cards/user-activity-analysis/`);
|
||||
if (!resUserActivity.ok) throw new Error('Error al obtener análisis de actividad de usuario');
|
||||
const dataUserActivity = await resUserActivity.json();
|
||||
setUserActivity(dataUserActivity);
|
||||
} catch (err) {
|
||||
console.error('Error fetching admin data:', err);
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user