Spaces:
Sleeping
Sleeping
| import * as React from 'react'; | |
| import Box from '@mui/material/Box'; | |
| import InputLabel from '@mui/material/InputLabel'; | |
| import MenuItem from '@mui/material/MenuItem'; | |
| import FormControl from '@mui/material/FormControl'; | |
| import Select from '@mui/material/Select'; | |
| export default function BasicSelect({label, content, styling, onChange}) { | |
| const [selectedValue, setSelectedValue] = React.useState(''); | |
| const handleChange = (event) => { | |
| const selectedValue = event.target.value; | |
| setSelectedValue(selectedValue); | |
| // Call the provided onChange callback with the selected value | |
| if (onChange) { | |
| onChange(event.target.value); | |
| } | |
| }; | |
| return ( | |
| <div className={styling}> | |
| <Box sx={{ minWidth: 120 }}> | |
| <FormControl fullWidth> | |
| <InputLabel id="demo-simple-select-label">{label}</InputLabel> | |
| <Select | |
| labelId="demo-simple-select-label" | |
| id="demo-simple-select" | |
| value={selectedValue} | |
| label="Value" | |
| onChange={handleChange} | |
| > | |
| {content.map((item) => { | |
| return <MenuItem value={item.id}>{`[${item.id}] ${item.name}`}</MenuItem> | |
| })} | |
| </Select> | |
| </FormControl> | |
| </Box> | |
| </div> | |
| ); | |
| } |