import React, { Component } from 'react';
import { observer } from 'mobx-react';
import { WeaTable } from 'ecCom';
import Detail from './Detail';

@observer
export default class DataList extends Component {
    componentDidMount() {window.addEventListener('resize', this.resizeHandle)}

    componentWillUnmount() {window.removeEventListener('resize', this.resizeHandle)}

    resizeHandle = e => this.props.store.reCalculateTableHeight = new Date().getTime();

    render() {
        const {store: {tableHeihgt, tableProps}, store} = this.props;

        return (
            <div className='dataList' style={{height: tableHeihgt}}>
                <div><WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@7etw1f`} {...tableProps}/></div>
                <Detail ecId={`${this && this.props && this.props.ecId || ''}_Detail@hb675d`} store={store}/>
            </div>
        )
    }
}