'use client'; import { X } from 'lucide-react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { typeLabel } from '@/lib/site'; import { COMPARE_MAX, COMPARE_MIN, compareHref, useCompareTray } from './compare-store'; /** * Floating tray summary shown on listings while the visitor collects entities: "n selected · Compare →". * Fixed above the mobile tab bar (< md) and bottom-right on desktop. Hidden on /compare itself and when empty. */ export function CompareTrayBar() { const tray = useCompareTray(); const pathname = usePathname(); if (!tray.ready || tray.items.length === 0 || pathname === '/compare') return null; const can = tray.items.length >= COMPARE_MIN; return (

{tray.items.length} / {COMPARE_MAX} {tray.type ? typeLabel(tray.type, true).toLowerCase() : 'selected'} · {tray.items.map((i) => i.name).slice(0, 3).join(', ')}{tray.items.length > 3 ? ` +${tray.items.length - 3}` : ''}

{can ? ( Compare → ) : ( Pick {COMPARE_MIN - tray.items.length} more )}
); }