import { ArrowDown, ArrowUp } from "lucide-react"; import { type Column } from "./DataTable"; import { type SortState } from "../lib/columnSort"; // A sort control for views without clickable column headers (the channel manager's card layout): // a dropdown of the sortable columns + an asc/desc toggle, mirroring the feed toolbar's sort. It's // driven by the SAME `SortState` the DataTable header uses, so table and cards stay in sync. The // dropdown's options come straight from the columns' `sortable`/`sortValue` metadata — no new list. export default function ColumnSortControl({ columns, sort, onChange, label, defaultLabel, ascLabel, descLabel, }: { columns: Column[]; sort: SortState; onChange: (next: SortState) => void; /** Accessible name for the dropdown (e.g. "Sort"). */ label: string; /** The "no sort / original order" option's text. */ defaultLabel: string; ascLabel: string; descLabel: string; }) { const sortable = columns.filter((c) => c.sortable && c.sortValue); // A stored sort can name a column this table no longer offers (renamed, or `sortable` dropped). // `sortRows` already leaves the rows unsorted then, so treat it as no sort here too — otherwise the // select falls back to showing "default" while a direction arrow claims a sort that isn't applied. const active = sortable.some((c) => c.key === sort?.key) ? sort : null; return (
{active && ( )}
); }