'use client';

import { useProduct } from '@/lib/product-context';

export function ProductSwitcher() {
  const { productId, setProductId, products } = useProduct();

  // Single-tenant deployments (a solo dev / freelancer with one project) get no
  // switcher clutter — there is nothing to switch between.
  if (products.length <= 1) return null;

  return (
    <select
      value={productId}
      onChange={e => setProductId(e.target.value)}
      className="h-8 rounded-md border border-border bg-card px-2 text-sm font-medium text-foreground focus:outline-none focus:ring-2 focus:ring-ring"
      aria-label="Select product"
    >
      {products.map(p => (
        <option key={p.id} value={p.id}>
          {p.name}
        </option>
      ))}
    </select>
  );
}
