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 fetchVendorList = async (q) => {
  const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/VendorList`, { q });
  return errcode !== 0 ? [] : result;
};

const VendorSelector = ({ ...props }) => {
  const { t } = useTranslation();
  return (
    <>
      <SearchInput
        placeholder={t('products:Vendor')}
        mode={'multiple'}
        maxTagCount={0}
        {...props}
        fetchOptions={fetchVendorList}
        map={{ travel_agency_name: 'label', travel_agency_id: 'value' }}
      />
    </>
  );
};
export default VendorSelector;
