import { CircleMinus, CircleX, TicketCheck } from 'lucide-react';

import { Badge } from '@/components/ui/badge';
import type { UploadListItem } from '@/types';

export function UploadResultCell({ item }: { item: UploadListItem }) {
  if (item.result === 'ticket_created') {
    return (
      <div className="space-y-1">
        <Badge className="bg-violet-500/15 text-violet-600 dark:text-violet-400">
          <TicketCheck /> Ticket Created
        </Badge>
        <p className="text-xs font-medium">
          {item.ticket_name ?? item.ticket_id}
        </p>
      </div>
    );
  }

  if (item.result === 'analysis_failed') {
    return (
      <div className="space-y-1 text-red-600 dark:text-red-400">
        <div className="flex items-center gap-1.5 text-xs font-medium">
          <CircleX className="size-3.5" /> Analysis Failed
        </div>
        <p className="text-xs text-muted-foreground">
          {item.error_message ?? 'Processing failed'}
        </p>
      </div>
    );
  }

  if (item.result === 'no_defects_found') {
    return (
      <div className="space-y-1">
        <div className="flex items-center gap-1.5 text-xs font-medium text-amber-500">
          <CircleMinus className="size-3.5" /> No Defects Found
        </div>
        <p className="text-xs text-muted-foreground">
          {item.total_detections ?? 0} issues detected
        </p>
      </div>
    );
  }
  return <span className="text-muted-foreground">—</span>;
}
