import React from 'react';
import styles from './index.less';
import ReactDom from "react-dom";
import HistoryList from "./HistoryList";

class HistoryCaseContainer extends React.Component {
    constructor(props){
        super(props);
        this.showHistoryBox = this.showHistoryBox.bind(this);
    }
    showHistoryBox(){   
      const {showHistoryBox} = this.props
      showHistoryBox&&showHistoryBox()
    }
    render(){
        const { visible,showHistoryCases,showHistoryBox,items,handleCaseClick,handleQuoteClick,handleSortClick,activeHistory,preInfo } = this.props;
        const domNode = document.getElementById('root');
        return ReactDom.createPortal(
              showHistoryCases?<React.Fragment>
                <div className={styles.maskHistory} onClick={this.showHistoryBox}></div>
                <HistoryList 
                    items={items}
                    showHistoryCases={showHistoryCases}
                    activeHistory={activeHistory}
                    showHistoryBox={this.showHistoryBox}
                    handleCaseClick={handleCaseClick}
                    handleQuoteClick={handleQuoteClick}
                    handleSortClick={handleSortClick}
                    preInfo={preInfo}
                ></HistoryList>
            </React.Fragment>:null
        ,domNode)
    }
}

export default HistoryCaseContainer;