import React, {useState} from 'react';
import classname from 'classnames'
import './index.less'


const Index = (props) => {
    const [status, setStatus] = useState(false);

    const topSearch = () => {
        const input = document.getElementsByClassName("auto-com-input");
        let inputValue = input[0].value;
        setStatus(inputValue != null && inputValue !== '')
    };
    const enterPress = (e) => {
        const input = document.getElementsByClassName("auto-com-input");
        if (e.keyCode === 13) {
            props.onSearch(input[0].value);
        }
    };
    return (
        <div className="search-box">
            <input {...props.cForm} onChange={topSearch} onKeyDown={enterPress} className={classname('auto-com-input', props.className)}/>
        </div>
    );
};

export default Index;
