index.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {Card, Table} from 'antd';
  2. import {FC} from 'react';
  3. import StorageModal from './modal';
  4. import {usePage} from '@hooks';
  5. import {pageContext} from '../context';
  6. import {useHandle, useList} from './hooks';
  7. import {PAGE_SIZE_LIST} from '@utils';
  8. import {TableTools} from '@components';
  9. const TableList: FC = function() {
  10. const [{page, pageSize}, {onPageChange}] = usePage(pageContext);
  11. const [{data, isFetching, count}, {refetch}] = useList();
  12. const [{columns, visible, editId}, {onAdd, onClose}] = useHandle(refetch);
  13. return (
  14. <>
  15. <Card className='table-wrapper'>
  16. <TableTools onClick={onAdd} />
  17. <Table
  18. data-testid='storage_table'
  19. bordered
  20. columns={columns}
  21. pagination={{
  22. current: page,
  23. showSizeChanger: true,
  24. pageSize,
  25. pageSizeOptions: PAGE_SIZE_LIST,
  26. onChange: onPageChange,
  27. total: count,
  28. }}
  29. loading={isFetching}
  30. dataSource={data}
  31. rowKey='id'
  32. />
  33. </Card>
  34. <StorageModal visible={visible} onClose={onClose} onFetch={refetch} id={editId} />
  35. </>
  36. );
  37. };
  38. export default TableList;