import React, { Fragment } from 'react';
import { Table, Pagination } from 'antd';
import './index.scss';

export default (props) => {
  const { loading, dataSource, columns, handleRow, total, setCurPage, current, rowSelection, expandedRowRender, expandIconColumnIndex, expandIconAsCell, onShowSizeChange, showSizeChanger, pagination, scroll } = props;

  return (
    <div className='pagination-table'>
      <Table
        {...props}
        loading={loading}
        rowKey={(row,i) => row.id || i}
        dataSource={dataSource}
        columns={columns}
        pagination={false}
        onRow={handleRow}
        rowSelection={rowSelection}
        expandedRowRender={expandedRowRender}
        expandIconColumnIndex={expandIconColumnIndex}
        expandIconAsCell={expandIconAsCell}
        scroll={scroll}
      />
      {total > 10 && (!pagination) &&
        <Pagination
          showQuickJumper
          onShowSizeChange={onShowSizeChange}
          onChange={setCurPage}
          current={current}
          total={total}
          showSizeChanger={showSizeChanger}
        />}
    </div>

  )
}
