import { createContext, useEffect, useState } from 'react';
import {} from 'antd';
import SearchInput from './SearchInput';
import { fetchJSON } from '@/utils/request';
import { HT_HOST } from '@/config';
import { useTranslation } from 'react-i18next';

//供应商列表
export const fetchCityList = async (q) => {
  const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/search_cities`, { q });
  return errcode !== 0 ? [] : result;
};

const CitySelector = ({ ...props }) => {
  const { t } = useTranslation();
  return (
    <>
      <SearchInput
        placeholder={t('products:City')}
        mode={null}
        maxTagCount={0}
        {...props}
        fetchOptions={fetchCityList}
        map={{ city_name: 'label', city_id: 'value' }}
      />
    </>
  );
};
export default CitySelector;
