'use client' import type { SignalSource } from '@/lib/api' interface Props { sources: SignalSource[] activeSource: string onChange: (src: string) => void /** Count map keyed by source (computed by parent from live post list). */ liveCounts: Record } function relativeTime(iso: string | null): string { if (!iso) return '—' const diff = (Date.now() - new Date(iso).getTime()) / 1000 if (diff < 60) return `${Math.round(diff)}s ago` if (diff < 3600) return `${Math.round(diff / 60)}m ago` if (diff < 86400) return `${Math.round(diff / 3600)}h ago` return `${Math.round(diff / 86400)}d ago` } /** * Source filter chips for the signals page. * * Each chip = one entry from /api/signals/sources. Shows total historical * count from the server + the (filtered) live count from the current post * payload — so the user can see "this filter would drop me from 700 to 13". */ export default function SourceChips({ sources, activeSource, onChange, liveCounts }: Props) { // Always have an "all" pseudo-source first const totalCount = sources.reduce((s, x) => s + x.count, 0) return (
Signal sources
{/* All */} {sources.map(s => ( ))}
) }