'use client'; import { useState, useEffect } from 'react'; import Link from 'next/link'; import { Plus, Users, Activity, TrendingUp, Calendar, Settings, FileText, Database, Layout, BarChart3, ArrowUpRight } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { adminService, UserStats } from '@/services/admin/user/adminService'; import { useToast } from '@/hooks/use-toast'; import { useCurrentUser } from '@/hooks/use-current-user'; export function Dashboard() { const [stats, setStats] = useState({ total: 0, growthRate: 0, activeUsers: 0, activeSessionsCount: 0, newUsersThisMonth: 0 }); const [loading, setLoading] = useState(true); const { toast } = useToast(); const { user, isLoading: userLoading } = useCurrentUser(); // Cargar estadísticas useEffect(() => { const loadStats = async () => { try { setLoading(true); const userStats = await adminService.getUserStats(); setStats(userStats); } catch (error) { const errorMessage = error instanceof Error ? error.message : "No se pudieron cargar las estadísticas"; toast({ title: "Error", description: errorMessage, variant: "destructive" }); setStats({ total: 5, growthRate: 20, activeUsers: 3, activeSessionsCount: 2, newUsersThisMonth: 1 }); } finally { setLoading(false); } }; loadStats(); }, [toast]); const userName = user?.name || 'Administrador'; const currentHour = new Date().getHours(); const greeting = currentHour < 12 ? 'Buenos días' : currentHour < 18 ? 'Buenas tardes' : 'Buenas noches'; // Loading state if (loading || userLoading) { return (

Cargando dashboard...

); } return (
{/* Clean editorial background */}
{/* Editorial header */}

{greeting}, {userName}

Panel de administración

{/* Stats Cards - Editorial Style */}
{/* Total Users */}

{loading ? '...' : stats.total}

Total usuarios

+{loading ? '0' : stats.growthRate}%
este mes
{/* Active Users */}

{loading ? '...' : stats.activeUsers}

Usuarios activos

{loading ? '0' : stats.activeSessionsCount} sesiones
activas
{/* New Users */}

{loading ? '...' : stats.newUsersThisMonth}

Nuevos este mes

Crecimiento
mensual
{/* System Status */}

100%

Sistema

Operativo
{/* Quick Actions Grid - Editorial Style */}

Acciones rápidas

{/* Users Management */}

Gestión de usuarios

Administrar usuarios y permisos

{/* Content Management */}

Ver contenido

Revisar y gestionar contenido

{/* Templates */}

Plantillas

Gestionar plantillas de contenido

{/* Content Types */}

Tipos de contenido

Configurar tipos de contenido

{/* Plugins */}

Plugins

Gestionar extensiones y plugins

{/* Settings */}

Configuración

Ajustes del sistema

); }