import { Card } from '@/components/ui/card';
import { Activity } from 'lucide-react';
import { SystemPerformance } from '@/types/monitor';

interface TomcatInfoCardProps {
  performance: SystemPerformance;
}

export function TomcatInfoCard({ performance }: TomcatInfoCardProps) {
  if (!performance.tomcat) {
    return null;
  }

  return (
    <Card className="p-6">
      <div className="flex items-center gap-2 mb-4">
        <Activity className="w-5 h-5 text-red-600" />
        <h3>Tomcat信息</h3>
      </div>
      <div className="grid grid-cols-2 md:grid-cols-5 gap-4">
        <div>
          <p className="text-sm text-muted-foreground">线程数</p>
          <p className="mt-1">
            {performance.tomcat.threadCount} / {performance.tomcat.maxThreads}
          </p>
        </div>
        <div>
          <p className="text-sm text-muted-foreground">连接数</p>
          <p className="mt-1">{performance.tomcat.connectionCount}</p>
        </div>
        <div>
          <p className="text-sm text-muted-foreground">请求数</p>
          <p className="mt-1">{performance.tomcat.requestCount.toLocaleString()}</p>
        </div>
        <div>
          <p className="text-sm text-muted-foreground">错误数</p>
          <p className="mt-1 text-red-600">{performance.tomcat.errorCount}</p>
        </div>
        <div>
          <p className="text-sm text-muted-foreground">错误率</p>
          <p className="mt-1">
            {((performance.tomcat.errorCount / performance.tomcat.requestCount) * 100).toFixed(2)}%
          </p>
        </div>
      </div>
    </Card>
  );
}