File size: 1,934 Bytes
0a903c7 8e222fd 8d2a400 1a156e6 b0b89da 0a903c7 1a156e6 0a903c7 1a156e6 0a903c7 1a156e6 8d2a400 1a156e6 0a903c7 1a156e6 0a903c7 1a156e6 0a903c7 b0b89da 8d2a400 1a156e6 8e222fd 1a156e6 0a903c7 1a156e6 0a903c7 1a156e6 0a903c7 1a156e6 0a903c7 1a156e6 0a903c7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
import { ReactComponent as NavigationPointerIcon } from '@/assets/svg/navigation-pointer.svg';
import NewDocumentLink from '@/components/new-document-link';
import { useGetDocumentUrl } from '@/hooks/documentHooks';
import { ITestingDocument } from '@/interfaces/database/knowledge';
import { isPdf } from '@/utils/documentUtils';
import { Table, TableProps } from 'antd';
import { useDispatch, useSelector } from 'umi';
interface IProps {
handleTesting: () => Promise<any>;
}
const SelectFiles = ({ handleTesting }: IProps) => {
const documents: ITestingDocument[] = useSelector(
(state: any) => state.testingModel.documents,
);
const dispatch = useDispatch();
const getDocumentUrl = useGetDocumentUrl();
const columns: TableProps<ITestingDocument>['columns'] = [
{
title: 'Name',
dataIndex: 'doc_name',
key: 'doc_name',
render: (text) => <p>{text}</p>,
},
{
title: 'Hits',
dataIndex: 'count',
key: 'count',
width: 80,
},
{
title: 'View',
key: 'view',
width: 50,
render: (_, { doc_id, doc_name }) => (
<NewDocumentLink
link={getDocumentUrl(doc_id)}
preventDefault={!isPdf(doc_name)}
>
<NavigationPointerIcon />
</NewDocumentLink>
),
},
];
const rowSelection = {
onChange: (selectedRowKeys: React.Key[]) => {
dispatch({
type: 'testingModel/setSelectedDocumentIds',
payload: selectedRowKeys,
});
handleTesting();
},
getCheckboxProps: (record: ITestingDocument) => ({
disabled: record.doc_name === 'Disabled User', // Column configuration not to be checked
name: record.doc_name,
}),
};
return (
<Table
columns={columns}
dataSource={documents}
showHeader={false}
rowSelection={rowSelection}
rowKey={'doc_id'}
/>
);
};
export default SelectFiles;
|