'use client' import { useState, useEffect } from 'react' import { useCSFApi } from '@/hooks/use-csf-api' function formatBytes(bytes: number): string { const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'] if (bytes === 0) return '0 Bytes' const i = Math.floor(Math.log(bytes) / Math.log(1024)) return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i] } function formatUptime(seconds: number): string { const days = Math.floor(seconds / 86400) const hours = Math.floor((seconds % 86400) / 3600) const minutes = Math.floor((seconds % 3600) / 60) if (days > 0) { return `${days}d ${hours}h ${minutes}m` } else if (hours > 0) { return `${hours}h ${minutes}m` } else { return `${minutes}m` } } interface StatsCardProps { title: string value: string | number subtitle?: string color?: 'blue' | 'green' | 'red' | 'yellow' | 'purple' icon?: React.ReactNode } function StatsCard({ title, value, subtitle, color = 'blue', icon }: StatsCardProps) { const colorClasses = { blue: 'bg-blue-500', green: 'bg-green-500', red: 'bg-red-500', yellow: 'bg-yellow-500', purple: 'bg-purple-500' } return (
{icon && (
{icon}
)}

{title}

{value}

{subtitle &&

{subtitle}

}
) } interface ProgressBarProps { percentage: number color?: 'blue' | 'green' | 'red' | 'yellow' label: string } function ProgressBar({ percentage, color = 'blue', label }: ProgressBarProps) { const colorClasses = { blue: 'bg-blue-500', green: 'bg-green-500', red: 'bg-red-500', yellow: 'bg-yellow-500' } const getColor = () => { if (percentage >= 90) return 'red' if (percentage >= 70) return 'yellow' return color } const currentColor = getColor() return (
{label} {percentage.toFixed(1)}%
) } interface ServerStatsProps { className?: string } export function ServerStats({ className = '' }: ServerStatsProps) { const { stats, getStats, loading } = useCSFApi() useEffect(() => { getStats() const interval = setInterval(getStats, 5000) // Update every 5 seconds return () => clearInterval(interval) }, [getStats]) if (!stats) { return (
) } const cpuIcon = ( ) const memoryIcon = ( ) const diskIcon = ( ) const networkIcon = ( ) return (

Estadísticas del Servidor

{/* Resource Usage */}
{/* Network Stats */}
{/* CSF Stats */}
} /> } /> } />
{loading && (
Actualizando estadísticas...
)}
) }