padding: theme.spacing.unit,
},
checkBoxCell: {
- // border: '1px dotted green',
padding: '0',
cursor: 'pointer',
},
},
});
-type DataTableState = {
- // checkedList: Record<string, boolean>;
-};
+type DataTableState = Record<string, boolean>;
-type DataTableProps<T> = DataTableDataProps<T> & WithStyles<CssRules> & DataTableState;
+type DataTableProps<T> = DataTableDataProps<T> & WithStyles<CssRules>;
export const DataTable = withStyles(styles)(
class Component<T> extends React.Component<DataTableProps<T>> {
- state: DataTableState = {
- // checkedList: {},
- };
+ state: DataTableState = {};
componentDidUpdate(prevProps: Readonly<DataTableProps<T>>) {
if (prevProps.items !== this.props.items) {
- // console.log('BEFORE INIT', this.state);
this.initializeCheckedList(this.props.items);
- // console.log('AFTER INIT', this.state);
}
}
),
};
- initializeCheckedList = async (uuids: any[]) => {
- let checkedList = this.state;
+ initializeCheckedList = (uuids: any[]): void => {
+ const checkedList = this.state;
uuids.forEach((uuid) => {
if (!checkedList.hasOwnProperty[uuid]) {
checkedList[uuid] = false;
});
};
- handleCheck = (uuid: string) => {
+ handleCheck = (uuid: string): void => {
const newCheckedList = { ...this.state };
newCheckedList[uuid] = !this.state[uuid];
this.setState(newCheckedList);
+ console.log(newCheckedList);
};
- handleSelectAll = () => {
+ handleSelectAll = (): void => {
const newCheckedList = { ...this.state };
for (const key in newCheckedList) {
newCheckedList[key] = true;
this.setState(newCheckedList);
};
- handleDeselectAll = () => {
+ handleDeselectAll = (): void => {
const newCheckedList = { ...this.state };
for (const key in newCheckedList) {
newCheckedList[key] = false;
this.setState(newCheckedList);
};
- handleInvertSelect = () => {
+ handleInvertSelect = (): void => {
const newCheckedList = { ...this.state };
for (const key in newCheckedList) {
newCheckedList[key] = !this.state[key];
const { items, classes, working, columns } = this.props;
if (columns[0].name === this.checkBoxColumn.name) columns.shift();
columns.unshift(this.checkBoxColumn);
- console.log('ONCHECK', this.state);
return (
<div className={classes.root}>