import React from 'react'
import { Table } from 'antd'
import Styles from './style.less'

const Actions = (props) => {
  const style = {
    padding: '1em',
  }

  return (
    <div className={Styles['flex-right']} style={style}>
      <div className={Styles['flex-right-item']}>{props.children}</div>
    </div>
  )
}

export default (props) => {
  const { actionRender, ...leftProps } = props

  const tableProps = {
    ...leftProps,
    pagination: false,
  }
  
  return (
    <div className={Styles['box-wrapper']}>
      {typeof actionRender === 'function' && <Actions>{actionRender()}</Actions>}
      <Table {...tableProps} />
    </div>
  )
}
