import React, { useEffect } from 'react';
import { connect } from 'umi';
import SearchOptions from './SearchOptions';
import SearchOptionsTow from './SearchOptionsTow';


const SearchOptionsCommnity = (props: any) => {
  
  const {dispatch, CommunityList, opname ,defaultName} = props;
  
  const tosCommunityget = (values:any) => {dispatch({type: 'Init/tosCommunityget',playload:values})};  
  useEffect(() => {
    if (CommunityList == null) {
      tosCommunityget(null)
    }
  }, []); 

  
  const extendName = (values: any) => {
    // console.log(values)
    opname(values)
  }

 

  return (
    <>{CommunityList!=null?
      // <SearchOptions 
      //   titleSearch={titleSearch} 
      //   disabled={disabled} 
      //   placeholder={placeholder} 
      //   defaultValue={props.defaultValue!=null?props.defaultValue:value} 
      //   list={CommunityList} 
      //   onSubmit={extendName} />

        <SearchOptionsTow list={CommunityList} extendName={extendName} def = {defaultName}></SearchOptionsTow>
      :null
      }
    </>
  );
};
function mapStateToProps(state:any) {
  const { CommunityList } = state.Init;  
  return {
    CommunityList,
  };
}
export default connect(mapStateToProps)(SearchOptionsCommnity);
// <SearchOptionsCommnity onSubmit={extendName} />
