import {
	observer
} from 'mobx-react';
import {
	WeaTab
} from 'ecCom';

@observer
export default class Tab extends React.Component {
	constructor(props) {
		super(props);
	}

	componentDidMount() {
		this.props.store.getSearchForm();
	}

	render() {
		const {
			store
		} = this.props, {
			tab,
			tabDatas,
			selectedKey,
			searchsBaseValue,
			showSearchAd,
			search,
			searchType,
		} = store, {
			form
		} = search;

		return (
			<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@42yyc4`} 
				{...tab}
				datas={tabDatas}
				showSearchAd={showSearchAd}
				searchType={searchType}
				searchsBaseValue={searchsBaseValue}
				selectedKey={selectedKey}
				searchsAd={<div
					onKeyDown={(e) =>( e.keyCode == 13 && e.target.tagName === "INPUT")  && tab.onSearch()}
				>{form.render()}</div>}
			/>
		);
	}
}