import MenuItem from "@mui/material/MenuItem"; import ListSubheader from "@mui/material/ListSubheader"; import Select from "@mui/material/Select"; import { styleTextSelectRight } from "@/mui"; import IconMultipleSelect from "@/components/icons/IconMultipleSelect"; function groupSpecialtiesByParent(specialties) { const groups = []; const parents = specialties.filter((item) => item.parent === null); parents.forEach((parent) => { const children = specialties.filter((item) => item.parent === parent.id); if (children.length > 0) { groups.push({ parent, children, }); } }); return groups; } export default function GroupedSelect({ list, name, updateData, data, nameKey = "name", }) { const groupedList = groupSpecialtiesByParent(list); const handleChange = (event) => { const value = event.target.value; updateData && updateData(value, "value", name); }; return (