import {
	Box,
	FormControl,
	MenuItem,
	OutlinedInput,
	Select,
} from "@mui/material";
import React from "react";

import style from "./BuzzSelect.module.css";

const ITEM_HEIGHT = 48;
const ITEM_PADDING_TOP = 8;
const MenuProps = {
	PaperProps: {
		style: {
			maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
			width: 250,
		},
	},
};

export default function BuzzSelect({
	id,
	label,
	value,
	menuList = [],
	onChange,
	valueKey = "value",
	labelKey = "label",
	disabled = false,
}) {
	return (
		<div className={style.container}>
			<Box className={style.labelRow}>
				<label>{label}</label>
			</Box>
			{/* <InputLabel>{label}</InputLabel> */}
			<FormControl id={id} fullWidth>
				<Select
					id={id}
					size="small"
					className={style.inputBox}
					value={value}
					onChange={onChange}
					input={<OutlinedInput />}
					MenuProps={MenuProps}
					disabled={disabled}
				>
					{menuList.map((option, index) => (
						<MenuItem key={index} value={option[valueKey]}>
							{option[labelKey]}
						</MenuItem>
					))}
				</Select>
			</FormControl>
		</div>
	);
}
