import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'

import { Table } from 'antd'
import { isFunction } from './utils'

export default class SearchBody extends PureComponent {
  static propTypes = {
    storage: PropTypes.object,
    dataSource: PropTypes.array,
    configs: PropTypes.object,
  }

  // storage = this.props.storage

  render() {
    const { dataSource, configs } = this.props
    const { render, ...leftProps } = configs || {}

    if (isFunction(render)) {
      return render(dataSource)
    }

    return (
      <Table pagination={false} dataSource={dataSource} {...leftProps} />
    )
  }
}
