Skip to content

Commit

Permalink
refactor(TreeTable): remove deprecated TableRowSelection props
Browse files Browse the repository at this point in the history
  • Loading branch information
saha80 authored and Rozhkow committed Dec 5, 2023
1 parent 21596fd commit f2daa34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
35 changes: 15 additions & 20 deletions src/components/tables/TreeTable/TreeTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useCallback } from 'react';
import { BaseTable } from '@app/components/common/BaseTable/BaseTable';
import { Key, DefaultRecordType } from 'rc-table/lib/interface';
import { TableRowSelection, ColumnsType } from 'antd/es/table/interface';
import { TreeTableRow, Pagination, getTreeTableData } from 'api/table.api';
import { useTranslation } from 'react-i18next';
import { useMounted } from '@app/hooks/useMounted';
Expand Down Expand Up @@ -39,19 +39,16 @@ export const TreeTable: React.FC = () => {
fetch(pagination);
};

const rowSelection = {
onChange: (selectedRowKeys: Key[], selectedRows: DefaultRecordType[]) => {
console.log(selectedRowKeys, selectedRows);
const rowSelection: TableRowSelection<TreeTableRow> = {
onChange: (selectedRowKeys: React.Key[], selectedRows: TreeTableRow[], info) => {
console.log(selectedRowKeys, selectedRows, info);
},
onSelect: (record: DefaultRecordType, selected: boolean, selectedRows: DefaultRecordType[]) => {
onSelect: (record: TreeTableRow, selected: boolean, selectedRows: TreeTableRow[]) => {
console.log(record, selected, selectedRows);
},
onSelectAll: (selected: boolean, selectedRows: DefaultRecordType[]) => {
console.log(selected, selectedRows);
},
};

const columns = [
const columns: ColumnsType<TreeTableRow> = [
{
title: t('common.name'),
dataIndex: 'name',
Expand All @@ -72,16 +69,14 @@ export const TreeTable: React.FC = () => {
];

return (
<>
<BaseTable
columns={columns}
dataSource={tableData.data}
rowSelection={{ ...rowSelection }}
pagination={tableData.pagination}
loading={tableData.loading}
onChange={handleTableChange}
scroll={{ x: 800 }}
/>
</>
<BaseTable
columns={columns}
dataSource={tableData.data}
rowSelection={rowSelection}
pagination={tableData.pagination}
loading={tableData.loading}
onChange={handleTableChange}
scroll={{ x: 800 }}
/>
);
};
3 changes: 2 additions & 1 deletion src/components/tables/editableTable/EditableTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useMounted } from '@app/hooks/useMounted';
import { BaseForm } from '@app/components/common/forms/BaseForm/BaseForm';
import { BaseSpace } from '@app/components/common/BaseSpace/BaseSpace';
import { BasePopconfirm } from '@app/components/common/BasePopconfirm/BasePopconfirm';
import { ColumnsType } from 'antd/es/table/interface';

const initialPagination: Pagination = {
current: 1,
Expand Down Expand Up @@ -135,7 +136,7 @@ export const EditableTable: React.FC = () => {
},
];

const mergedColumns = columns.map((col) => {
const mergedColumns: ColumnsType<BasicTableRow> = columns.map((col) => {
if (!col.editable) {
return col;
}
Expand Down

0 comments on commit f2daa34

Please sign in to comment.