import type { TFunction } from "i18next";
import { formatCountOrDash } from "../lib/format";
import type { Column } from "./DataTable";

/** The shared "subscribers" DataTable column (right-aligned, sortable, em-dash for null) — identical
 * in the Channels manager and the ChannelDiscovery table, which show subscriber counts on different
 * channel row shapes. */
export function subsColumn<T extends { subscriber_count: number | null }>(t: TFunction): Column<T> {
  return {
    key: "subs",
    header: t("channels.cols.subs"),
    align: "right",
    nowrap: true,
    sortable: true,
    sortValue: (c) => c.subscriber_count ?? -1,
    render: (c) => <span className="text-muted tabular-nums">{formatCountOrDash(c.subscriber_count)}</span>,
  };
}
