'use client';

import React from 'react';
import { Card } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Enterprise, AuditStatus } from '../types';

interface AuditStatusAlertProps {
  enterprise: Enterprise;
}

export function AuditStatusAlert({ enterprise }: AuditStatusAlertProps) {
  const getAuditStatusBadge = (status: AuditStatus) => {
    switch (status) {
      case 'pending':
        return <Badge className="bg-yellow-100 text-yellow-700">待审核</Badge>;
      case 'approved':
        return <Badge className="bg-green-100 text-green-700">已通过</Badge>;
      case 'rejected':
        return <Badge className="bg-red-100 text-red-700">已驳回</Badge>;
      default:
        return <Badge>{status}</Badge>;
    }
  };

  return (
    <Card className={`p-4 ${
      enterprise.auditStatus === 'pending' ? 'bg-yellow-50 border-yellow-200' :
      enterprise.auditStatus === 'rejected' ? 'bg-red-50 border-red-200' :
      'bg-green-50 border-green-200'
    }`}>
      <div className="flex items-center justify-between">
        <div>
          <div className="flex items-center gap-2">
            <span>当前审核状态：</span>
            {getAuditStatusBadge(enterprise.auditStatus)}
          </div>
          {enterprise.auditStatus === 'rejected' && enterprise.auditReason && (
            <p className="text-sm text-red-700 mt-2">
              驳回原因：{enterprise.auditReason}
            </p>
          )}
          {enterprise.auditStatus === 'pending' && (
            <p className="text-sm text-yellow-700 mt-2">
              信息修改后需要管理员重新审核
            </p>
          )}
        </div>
        {enterprise.auditTime && (
          <div className="text-sm text-muted-foreground">
            审核时间：{new Date(enterprise.auditTime).toLocaleString('zh-CN')}
          </div>
        )}
      </div>
    </Card>
  );
}