"use client"; import { PLATFORM_VALUES, type Platform } from "../../lib/platform"; import type { ChartFilters } from "../../lib/chartConfig"; import { ymdToInput, inputToYmd } from "../../lib/ymd"; export type ChannelOption = { slug: string; name: string }; const field = "rounded-md border border-border bg-card px-2 py-1 text-sm"; const label = "text-xs font-medium text-muted-foreground"; export function FilterBar({ filters, channels, onChange, }: { filters: ChartFilters; channels: ChannelOption[]; onChange: (next: ChartFilters) => void; }) { const set = (patch: Partial) => onChange({ ...filters, ...patch }); const toggleChannel = (slug: string) => { const cur = new Set(filters.channels ?? []); if (cur.has(slug)) cur.delete(slug); else cur.add(slug); set({ channels: cur.size ? Array.from(cur) : undefined }); }; const togglePlatform = (p: Platform) => { const cur = new Set(filters.platforms ?? []); if (cur.has(p)) cur.delete(p); else cur.add(p); set({ platforms: cur.size ? Array.from(cur) : undefined }); }; return (
Platform
{PLATFORM_VALUES.map((p) => { const on = filters.platforms?.includes(p) ?? false; return ( ); })}
{channels.length > 0 && (
Channels{filters.channels?.length ? ` (${filters.channels.length})` : ""}
{channels.map((c) => { const on = filters.channels?.includes(c.slug) ?? false; return ( ); })}
)}
); }