Rev 1838 | Rev 2108 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react'
import {
FormControl,
InputLabel,
MenuItem,
Select as MuiSelect
} from '@mui/material'
import FormErrorFeedback from '../form/FormErrorFeedback'
const Select = ({
label,
name,
value,
placeholder,
defaultValue,
options = [],
error = null,
inputRef = null,
onChange = () => {}
}) => {
return (
<FormControl fullWidth>
{label ? (
<InputLabel shrink htmlFor={name}>
{label}
</InputLabel>
) : null}
<MuiSelect
inputRef={inputRef}
defaultValue={defaultValue}
value={value}
onChange={onChange}
name={name}
id={name}
sx={{
borderRadius: '4px'
}}
fullWidth
displayEmpty
>
<MenuItem value=''>{placeholder}</MenuItem>
{options.map(({ name, value }) => (
<MenuItem key={value} value={value}>
{name}
</MenuItem>
))}
</MuiSelect>
{error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
</FormControl>
)
}
export default Select