import React from "react"; import { Hooks } from "react-table"; import { Operation } from "../../../interfaces"; import { DefaultCellOperations } from "../components/defaultCellOperations.component"; export type UseOperationsHookProps = { CellOperations?: React.ComponentType; operations: Operation[]; onClick?: (data: any, event: string) => void; i18n?: (f: string) => string; ctx?: any; }; export function useOperations({ operations, CellOperations = DefaultCellOperations, onClick, i18n = (f: string) => f, ctx }: UseOperationsHookProps) { return (hooks: Hooks): void => { hooks.visibleColumns.push((columns) => { if (!operations.length) { return columns; } return [ ...columns, { id: "operations", groupByBoundary: true, Header: () => (
{i18n("Operations")}
), Cell: (props: any) => ( ) } ]; }); }; }