import React from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Server, Database, Cpu, HardDrive, Activity, Zap } from "lucide-react"; import { fetchServer } from "@/lib/api"; import SystemStatusCard from "@/components/admin/SystemStatusCard"; import { MotionWrapper } from "@/components/ui/motion-wrapper"; export const dynamic = 'force-dynamic'; interface SystemStatus { uptimeSeconds: number; memory: { rss: number; heapTotal: number; heapUsed: number; external: number; arrayBuffers: number; }; versions: Record; counts: { vendors: number; orders: number; products: number; chats: number; }; } export default async function AdminStatusPage() { let systemStatus: SystemStatus | null = null; let error: string | null = null; try { systemStatus = await fetchServer("/admin/system-status"); } catch (err) { console.error("Failed to fetch system status:", err); error = "Failed to load system status"; } if (error) { return (

System Status

Monitor system health and real-time performance metrics

{error}

); } const formatUptime = (seconds: number) => { const days = Math.floor(seconds / 86400); const hours = Math.floor((seconds % 86400) / 3600); const minutes = Math.floor((seconds % 3600) / 60); return `${days}d ${hours}h ${minutes}m`; }; const formatBytes = (bytes: number) => { const sizes = ['Bytes', 'KB', 'MB', 'GB']; 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]; }; const memoryUsagePercent = systemStatus ? Math.round((systemStatus.memory.heapUsed / systemStatus.memory.heapTotal) * 100) : 0; return (

System Status

Monitor system health and real-time performance metrics

{/* Server Status */} Server Uptime
{systemStatus ? formatUptime(systemStatus.uptimeSeconds) : 'N/A'}
Online Checked: {new Date().toLocaleTimeString()}
{/* Database Status */} Database Health
{systemStatus ? `${(systemStatus.counts.vendors + systemStatus.counts.orders + systemStatus.counts.products).toLocaleString()}` : '0'} records
Connected 4 active collections
{/* Memory Usage */} Memory Usage
{systemStatus ? formatBytes(systemStatus.memory.heapUsed) : 'N/A'} used
80 ? 'bg-red-500/10 text-red-500 border-red-500/20' : memoryUsagePercent > 60 ? 'bg-yellow-500/10 text-yellow-500 border-yellow-500/20' : 'bg-purple-500/10 text-purple-500 border-purple-500/20'} `}> {memoryUsagePercent}% Load Total: {systemStatus ? formatBytes(systemStatus.memory.heapTotal) : 'N/A'}
{/* Platform Stats */} Platform Activity
{systemStatus ? systemStatus.counts.vendors : '0'} Active Vendors
Live {systemStatus ? `${systemStatus.counts.orders} orders` : '0 orders'}
{/* Runtime Info */} Runtime Environment

Node.js

Runtime

{systemStatus ? `v${systemStatus.versions.node}` : 'N/A'}

V8

Engine

{systemStatus ? systemStatus.versions.v8 : 'N/A'}
Performance Optimized
); }