import React from 'react'                      
import {Select, SelectProps} from "antd";
import "./Select.scss"

interface StarshipSelectProps {
  options: {
    label: string,
    value: string | number | undefined | null
    icon?: React.ReactNode
  }[]
}

const StarshipSelect = (props: Omit<SelectProps,"options"> & StarshipSelectProps) => {
  const {className, dropdownClassName,options, ...restProps} = props;
  return (
    <Select
    className={`starship-select-field ${className}`}
    popupClassName={`starship-dropdown ${dropdownClassName}`}
    {...restProps}
    >
      {options.map(({value, icon, label}) => <Select.Option value={value}> {icon && <span>{icon}</span>} {label}</Select.Option>)}
    </Select>
  )
}

export default StarshipSelect