import { ComponentType } from 'react'; import { TableCell } from '@servicetitan/design-system'; import { TableCellProps } from '../table'; import { PossibleFormState } from '../table-state'; export interface EditActionProps extends TableCellProps { formState: PossibleFormState; } interface GetActionCellParams { view: ComponentType>; edit: ComponentType>; } export function getActionCell({ view: ViewAction, edit: EditAction }: GetActionCellParams) { return (props: TableCellProps) => { const { tableState, dataItem, rowType } = props; if (rowType !== 'data') { return ; } const editingForm = tableState?.dataSource?.idSelector && tableState.inEdit.get(tableState.dataSource.idSelector(dataItem)); if (editingForm) { return ; } return ; }; }