Rev 1538 | Rev 1542 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useState } from 'react'
import {
List,
ListItem,
ListItemButton,
ListItemText,
Typography
} from '@mui/material'
import WidgetWrapper from 'components/widgets/WidgetLayout'
const SideMenu = ({ items = [], onChange = null, title = '' }) => {
const [currentIndex, setCurrentIndex] = useState(0)
const handleChange = (index, value) => {
setCurrentIndex(index)
onChange(value)
}
return (
<WidgetWrapper p={1}>
<Typography variant='h2'>{title}</Typography>
<List sx={{ mt: 1 }}>
{items.map(({ value, name }, index) => (
<ListItem
key={value}
sx={{
p: 0,
fontWeight: currentIndex === index ? 'bold' : 'normal'
}}
>
<ListItemButton onClick={() => handleChange(index, value)}>
<ListItemText id={value} primary={name} />
</ListItemButton>
</ListItem>
))}
</List>
</WidgetWrapper>
)
}
export default SideMenu