import {
    inject,
    observer
} from 'mobx-react'
import {
    WeaTab
} from 'ecCom'

@inject('hrmUsedemand') //todo
@observer
export default class Tab extends React.Component {
    constructor(props) {
        super(props);
    }

    componentDidMount() {
        const {
            hrmUsedemand
        } = this.props, {
            mainDialog
        } = hrmUsedemand, {
            type
        } = mainDialog;

        type == 'bar' && this.props.hrmUsedemand.getSearchCondition();
    }

    componentWillUnmount() {
        this.props.hrmUsedemand.resetTab();
    }

    render() {
        const {
            hrmUsedemand
        } = this.props, {
            tab,
            buttonsAd,
            changePanelStatus,
            searchsAd,
            handleSearch,
            mainDialog,
            setSearchBaseValue,
        } = hrmUsedemand, {
            isPanelShow,
            conditionCount,
            form,
            searchBaseValue,
        } = tab, {
            type
        } = mainDialog;

        return (
            <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@92f8wd`}
                searchType={(type=='more0' || type == 'more1') ? ['base'] : ['base','advanced']}
                showSearchAd={isPanelShow}
                hasMask={false}
                advanceHeight={Math.ceil(conditionCount / 2)*52+20}
                buttonsAd={buttonsAd}
                searchsBaseValue={searchBaseValue }
                setShowSearchAd={  b => changePanelStatus(b)}
                hideSearchAd={ () => changePanelStatus(false)}
                searchsAd= {searchsAd}
                onSearch={() => handleSearch()}
                onSearchChange={val => setSearchBaseValue(val) }
            />
        )

    }
}