import React from 'react'
import { Table } from 'antd'
import { connect } from 'dva'
import resolveChartOption from '../../chart/resolveChartOption'
import './tableView.less'

const TableView = ({ contentSize, chartDesigner, dispatch }) => {
    const option = resolveChartOption(chartDesigner.chartOption);
    const { columns, data } = option;

    return (
        <Table
            className='table-view'
            columns={columns}
            dataSource={data}
            size='small'
            scroll={{
                x: columns ? columns.length * 100 : 0,
                y: contentSize.height - 38 - 42
            }}
        />
    );
}

function mapStateToProps({ present: { chartDesigner } }) {
    return { chartDesigner: chartDesigner }
}

export default connect(mapStateToProps)(TableView);