import React from 'react'; import { BeatLoader } from 'react-spinners'; import { Box } from '@chakra-ui/layout'; import { Button } from '@chakra-ui/button'; import { Menu, MenuButton, MenuItem, MenuList } from '@chakra-ui/menu'; import { ChevronDownIcon } from '@chakra-ui/icons'; /** * Types */ import type { OptionType } from '@educt/types'; export interface ISelectPropsType { options?: OptionType[]; value?: string; onChange: (newValue: string) => void; placeholder?: string; noOptionsMessage?: string; isLoading?: boolean; loadingText?: string; } const Select: React.FC = props => { const { options, value, noOptionsMessage, loadingText, isLoading } = props; return ( <> } rightIcon={} > {options?.find(option => option.value === value)?.label || props?.placeholder || 'Select Option'} {options && options.length !== 0 ? ( options.map(option => ( { props.onChange(option.value); }} > {option.label} )) ) : ( {noOptionsMessage || 'No options.'} )} ); }; export default Select;