import React from 'react';
import Header from '../../components/CommonComponent/HeaderComponent/HeaderComponent';
import LeftContainer from '../LeftContainer/LeftContainer';
import RightContainer from '../RightContainer/RightContainer';
import RecovertyFirstPage from '../../components/RecoveryComponent/RecoveryFirstPage/RecoveryFirstPage'
require('./index.css');

const recoveryPageIndex = {
    1 : "getFirstPage",
    2 : "getSecondPage",
    3 : "getScanPage"
}

export default class BoxRecoveryContainer extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            btnBlock : true //展示回收箱页面
        };
        this.getFirstPage = this.getFirstPage.bind(this); //展示第一页
        this.handleFinishBoxRecovery = this.handleFinishBoxRecovery.bind(this); //完成回收箱商品回收
    }

    componentWillMount() {
    }

    componentWillReceiveProps(nextProps){
    }

    handleFinishBoxRecovery(){
        //完成回收箱物品回收
        if(this.state.btnBlock){
            this.setState({
                btnBlock : false
            },()=>{
                let props = this.props;
                props.willCloseDoor()
            })
        }
    }

    getFirstPage(props){
        return (
            <RecovertyFirstPage handleFinishBoxRecovery={()=>this.handleFinishBoxRecovery()} {...props}/>
        )
    }


    render(){
        let props = this.props;
        let dom = this.getFirstPage(props);
        return(
            <div className={"recoveryContainer page"}>
                <div style={{width:'100%',height:'100%'}}>
                    {
                        props.headerInfo && props.headerInfo.storeInfo ?
                            <Header headerInfo={props.headerInfo}/> : null
                    }

                    <LeftContainer leftInfo={props.headerInfo}/>
                    <RightContainer>
                        {dom}
                    </RightContainer>
                </div>
            </div>
        )
    }
}
