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, type, disabled } = 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}s
        //   disabled={disabled}
        //   placeholder={placeholder}
        //   defaultValue={props.defaultValue!=null?props.defaultValue:value}
        //   list={CommunityList}
        //   onSubmit={extendName} />

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