"use client"; import { Button, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@repo/shadcn-ui/components"; import type { Column, Table } from "@tanstack/react-table"; import { Settings2 } from "lucide-react"; import { useTranslation } from "../../locales/i18n.ts"; export function DataTableViewOptions({ table }: { table: Table }) { const { t } = useTranslation(); return ( {t("components.datatable_view_options.toggle_columns")} {table .getAllColumns() .filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide()) .map((column) => { return ( column.toggleVisibility(!!value)} > {getColumnLabel(column)} ); })} ); } const getColumnLabel = (column: Column): string => { let label = String(column.id); const h = column.columnDef.header; // header como string literal if (typeof h === "string") label = h; // header función → intentar obtener title si lo usas en tus componentes if (typeof h === "function") { // tu DataTableColumnHeader recibe `title` como prop → está en column.columnDef.meta const meta = column.columnDef.meta as { title?: string } | undefined; label = meta?.title ?? column.id; } return label; };