import { cn } from '@/lib/utils'; import { SPOT_STATUS_META, statusTimeAgo } from '@/lib/spotStatus'; import type { AggregatedSpotStatus } from '@/hooks/useSpotStatus'; import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/tooltip'; interface SpotStatusBadgeProps { aggregated: AggregatedSpotStatus | null | undefined; /** Compact = dot + label only, no meta. */ size?: 'sm' | 'md'; className?: string; /** Hide the badge entirely when there are no reports (default true). */ hideWhenEmpty?: boolean; } /** * Displays the community-consensus status for a spot. * - No reports → renders nothing (unless hideWhenEmpty=false, then "Unverified"). * - Otherwise → colored badge with the winning status + reporter count tooltip. */ export function SpotStatusBadge({ aggregated, size = 'md', className, hideWhenEmpty = true, }: SpotStatusBadgeProps) { const status = aggregated?.status ?? null; if (!status) { if (hideWhenEmpty) return null; return ( Unverified ); } const meta = SPOT_STATUS_META[status]; const reporterCount = aggregated?.reporterCount ?? 0; const lastAt = aggregated?.lastReportedAt ?? null; const badge = ( {meta.label} ); return ( {badge}

{meta.label}

{meta.description}

{reporterCount} {reporterCount === 1 ? 'report' : 'reports'} {lastAt ? ` · last ${statusTimeAgo(lastAt)}` : ''}

); }