import React from 'react';
import { Select } from 'antd';
import { SelectProps } from '../editInterface';

export default function(props: SelectProps) {
    const { options = [], allowClear, disabled, placeholder, value, onChange, isMultiple } = props;
    const selfProps: any = { allowClear, disabled, placeholder, value, onChange };
    if (isMultiple) {
        selfProps.mode = 'multiple';
    }
    return (
        <Select {...selfProps}>
            {options.map((item) => (
                <Select.Option key={item.id} value={item.id}>
                    {item.name}
                </Select.Option>
            ))}
        </Select>
    );
}
