import { useState, useRef } from "react" import { Select as MuiSelect, MenuItem, Box, Typography, useTheme } from "@mui/material" import classnames from "classnames" import checkIcon from "@root/assets/Icons/check.svg" import "./select.css" import type { SelectChangeEvent } from "@mui/material" type SelectProps = { items: string[]; selectedItem: number; setSelectedItem: (num: number) => void; }; export const Select = ({ items, selectedItem, setSelectedItem }: SelectProps) => { const [opened, setOpened] = useState(false) const [currentValue, setCurrentValue] = useState(items[selectedItem]) const ref = useRef(null) const theme = useTheme() const selectItem = (event: SelectChangeEvent) => { setCurrentValue(items[Number(event.target.value)]) setSelectedItem(Number(event.target.value)) } return ( ref.current?.click()} > {currentValue} check setOpened((isOpened) => !isOpened)} MenuProps={{ disablePortal: true }} sx={{ width: "100%",zIndex: 1, }} onChange={selectItem} > {items.map((item, index) => ( {item} ))} ) }