import type { TripPilot } from '@/lib/data/dashboard-data'

/**
 * One pill per pilot car on a trip, with the states that pilot is assigned
 * (Nash, 2026-09-17): "if there is a pilot car that's assigned to a specific
 * state we should have that pilot car and the actual states where he is
 * assigned… if it's two different pilot cars and one is assigned for certain
 * states, another one for another one, it should visually represent that
 * there are two different pilot cars for that trip."
 *
 * Name and states only — the broker's rule (2026-09-13) keeps contact
 * details off the dashboard. A pilot with nothing shared yet still shows, so
 * the inviter can see there is someone to share with.
 */
export function PilotCarBadges({ pilots, className }: { pilots: TripPilot[]; className?: string }) {
  if (pilots.length === 0) return null
  return (
    <span className={`inline-flex flex-wrap gap-1 ${className ?? ''}`}>
      {pilots.map((p) => (
        <span
          key={p.participant_id}
          title={p.states.length ? `${p.name} · ${p.access}` : `${p.name} · nothing shared yet`}
          className="inline-flex items-center rounded-full bg-info-bg px-2 py-0.5 text-[10px] font-bold text-info ring-1 ring-inset ring-blue-200"
        >
          🚗 {p.name}
          {p.states.length ? ` · ${p.states.join(', ')}` : ' · no states yet'}
        </span>
      ))}
    </span>
  )
}
