import { Star } from 'lucide-react';

interface ProductRatingProps {
  rating: number;
  max?: number;
  showCount?: boolean;
  count?: number;
  size?: 'sm' | 'md' | 'lg';
}

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

export default function ProductRating({ rating, max = 5, showCount = false, count = 0, size = 'md' }: ProductRatingProps) {
  return (
    <div className="flex items-center gap-1">
      {[...Array(max)].map((_, i) => (
        <Star
          key={i}
          className={`${sizeClasses[size]} ${
            i < Math.round(rating)
              ? 'fill-yellow-400 text-yellow-400'
              : 'text-gray-300'
          }`}
        />
      ))}
      {showCount && (
        <span className="ml-1 text-sm text-gray-500">({count})</span>
      )}
      <span className="ml-1 text-sm font-medium">{rating.toFixed(1)}</span>
    </div>
  );
}
