Rev 1784 | Rev 1838 | 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 = '',
options = [],
inputRef = null,
name = '',
value = '',
onChange = () => {},
error = null
}) => {
return (
<FormControl fullWidth>
{label ? (
<InputLabel shrink htmlFor={name}>
{label}
</InputLabel>
) : null}
<MuiSelect
ref={inputRef}
value={value}
onChange={onChange}
name={name}
id={name}
fullWidth
>
{options.map(({ name, value }) => (
<MenuItem key={value} value={value}>
{name}
</MenuItem>
))}
</MuiSelect>
{error ? <FormErrorFeedback>{error}</FormErrorFeedback> : null}
</FormControl>
)
}
export default Select