import {
	inject,
	observer
} from 'mobx-react';
import {
	WeaTab,
} from 'ecCom';
@inject('commonStore')
@inject('hrmHolidayRule')
@observer
class Search extends React.Component {
	constructor(props) {
		super(props);
	}

	componentDidMount() {
		this.props.commonStore.getSearchCondition();
	}

	setShowSearchAd = (bool) => {
		this.props.commonStore.changeSearchPanelStatus(bool);
	}

	handleSearch = () => {
		this.props.commonStore.getSearchList();
	}

	handleSearchChange = (val) => {
		this.props.commonStore.changeAdvanceSearchField(val);
	}

	render() {
		const {
			search,
			searchBaseValue,
			searchsAd,
			buttonsAd,
			advanceHeight
		} = this.props.commonStore, {
			isPanelShow,
		} = search;

		return (
			<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@37tovc`} 
				searchsBaseValue={searchBaseValue}
				searchsAd={searchsAd}
				buttonsAd={buttonsAd}
				showSearchAd={isPanelShow}
				advanceHeight={advanceHeight}
				setShowSearchAd={this.setShowSearchAd}
				onSearch={this.handleSearch}
				onSearchChange={this.handleSearchChange}
				hasMask={false}
				searchType={['base','advanced']}/>
		)
	}
}

export default Search