import { Checkbox } from "@/ui";
import { DataTableColumnProps } from "./DataTable";

export function getDataTableSelectionColumn<TData, TError>(): DataTableColumnProps<TData, TError> {
  return {
    id: "select",
    header: ({ table }) => (
      <Checkbox
        id='select-all'
        checked={
          table.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && "indeterminate")
        }
        onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
        aria-label='Seleccionar todo'
        className='translate-y-[2px]'
      />
    ),
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    cell: ({ row }) => (
      <Checkbox
        id={`select-row-${row.id}`}
        checked={row.getIsSelected()}
        onCheckedChange={(value) => {
          row.toggleSelected(!!value);
        }}
        aria-label='Seleccionar file'
        className='translate-y-[2px]'
      />
    ),
    enableSorting: false,
    enableHiding: false,
  };
}
