'use client';

import React from 'react';
import { Card } from '@/components/ui/card';
import { AuditHistoryStats, AuditRecord } from '../types';

interface AuditHistoryStatsCardsProps {
  records: AuditRecord[];
}

export function AuditHistoryStatsCards({ records }: AuditHistoryStatsCardsProps) {
  const stats: AuditHistoryStats[] = [
    {
      label: '总审核数',
      value: records.length,
      color: 'text-blue-600',
      bg: 'bg-blue-100',
    },
    {
      label: '已通过',
      value: records.filter(r => r.result === 'approved').length,
      color: 'text-green-600',
      bg: 'bg-green-100',
    },
    {
      label: '已驳回',
      value: records.filter(r => r.result === 'rejected').length,
      color: 'text-red-600',
      bg: 'bg-red-100',
    },
    {
      label: '待审核',
      value: records.filter(r => r.result === 'pending').length,
      color: 'text-yellow-600',
      bg: 'bg-yellow-100',
    },
  ];

  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 ${stat.color} text-2xl font-semibold`}>{stat.value}</div>
        </Card>
      ))}
    </div>
  );
}