import { Package, AlertTriangle, CheckCircle, XCircle } from 'lucide-react';

interface StockBadgeProps {
  inventory: number;
  lowStockThreshold?: number;
  trackInventory?: boolean;
  showIcon?: boolean;
  size?: 'sm' | 'md' | 'lg';
}

export default function StockBadge({ 
  inventory, 
  lowStockThreshold = 5, 
  trackInventory = true,
  showIcon = true,
  size = 'md'
}: StockBadgeProps) {
  const sizeClasses = {
    sm: 'text-xs',
    md: 'text-sm',
    lg: 'text-base'
  };

  const iconSizes = {
    sm: 'w-3 h-3',
    md: 'w-4 h-4',
    lg: 'w-5 h-5'
  };

  if (!trackInventory) {
    return (
      <div className={`flex items-center gap-1.5 text-green-600 ${sizeClasses[size]}`}>
        {showIcon && <CheckCircle className={iconSizes[size]} />}
        <span>พร้อมส่ง</span>
      </div>
    );
  }

  if (inventory === 0) {
    return (
      <div className={`flex items-center gap-1.5 text-red-600 ${sizeClasses[size]}`}>
        {showIcon && <XCircle className={iconSizes[size]} />}
        <span>หมดสต็อก</span>
      </div>
    );
  }

  if (inventory <= lowStockThreshold) {
    return (
      <div className={`flex items-center gap-1.5 text-orange-600 ${sizeClasses[size]}`}>
        {showIcon && <AlertTriangle className={iconSizes[size]} />}
        <span>เหลือเพียง {inventory} ชิ้น</span>
      </div>
    );
  }

  return (
    <div className={`flex items-center gap-1.5 text-green-600 ${sizeClasses[size]}`}>
      {showIcon && <Package className={iconSizes[size]} />}
      <span>มีสินค้า ({inventory})</span>
    </div>
  );
}
