import { injectable } from '@servicetitan/react-ioc'; import { IdType, InMemoryDataSource, TableState } from '../..'; import { Product, UserRole, Supplier } from './product'; import { products } from './products'; @injectable() export class TableStore { rowIdKey: keyof Product = 'ProductID'; tableState = new TableState({ dataSource: this.getDataSource(), pageSize: 5, rowIdKey: this.rowIdKey, }); private getDataSource() { return new InMemoryDataSource(products, this.idSelector, { Supplier: (value: Supplier) => Supplier[value], AvailableFor: (value: UserRole | undefined) => value && UserRole[value], }); } private idSelector(row: Product) { return row[this.rowIdKey] as IdType; } }