25 lines
753 B
TypeScript
25 lines
753 B
TypeScript
import { FormControl, InputLabel, Select, MenuItem } from '@mui/material';
|
|
import { getFieldOptions } from '../../utils/options';
|
|
import { FieldComponentProps } from '../../types/overrides';
|
|
|
|
export default function EnumField({ field, value, onChange, disabled }: FieldComponentProps) {
|
|
const options = getFieldOptions(field);
|
|
return (
|
|
<FormControl fullWidth>
|
|
<InputLabel>{field.label}</InputLabel>
|
|
<Select
|
|
value={value || ''}
|
|
label={field.label}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
disabled={disabled}
|
|
>
|
|
{options.map((opt) => (
|
|
<MenuItem key={opt.key} value={opt.key}>
|
|
{opt.value}
|
|
</MenuItem>
|
|
))}
|
|
</Select>
|
|
</FormControl>
|
|
);
|
|
}
|