'use client';

import { Card } from '@/components/ui/card';
import { MessageLog } from '@/types/message';

interface MessageLogStatsProps {
  logs: MessageLog[];
}

export function MessageLogStats({ logs }: MessageLogStatsProps) {
  const stats = [
    {
      label: '总消息数',
      value: logs.length,
      color: 'text-blue-600',
    },
    {
      label: '已发送',
      value: logs.filter(l => l.status === 'sent' || l.status === 'read').length,
      color: 'text-green-600',
    },
    {
      label: '已读',
      value: logs.filter(l => l.status === 'read').length,
      color: 'text-purple-600',
    },
    {
      label: '发送失败',
      value: logs.filter(l => l.status === 'failed').length,
      color: 'text-red-600',
    },
  ];

  return (
    <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
      {stats.map((stat, index) => (
        <Card key={index} className="p-4">
          <div className="text-sm text-muted-foreground">{stat.label}</div>
          <div className={`mt-2 text-2xl font-bold ${stat.color}`}>{stat.value}</div>
        </Card>
      ))}
    </div>
  );
}