import React from 'react';
import InputSearch from '../../extra/dataEntry/textSelect';
import { ApolloInputSearchProps } from '../editInterface';
import { antiAssign } from '../../../../utils/utils';
import s from './index.less';

export const ApolloInputSearch = (props: ApolloInputSearchProps) => {
    const { onChange, request } = props;
    const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'request']);

    const changeValue = (value) => {
        if (typeof onChange === 'function') {
            onChange(value, value);
        }
    };

    return (
        <InputSearch
            className={s.select}
            request={request}
            fieldNames={{ value: 'fieldValueValue', label: 'fieldValueName' }}
            {...selfProps}
            onChange={changeValue}
            initDataType="onfocus"
        />
    );
};
