Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1535 | Rev 1538 | 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, 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>
        {items.map(({ value, name }, index) => (
          <ListItem
            key={value}
            sx={{ fontWeight: currentIndex === index ? 'bold' : 'normal' }}
          >
            <ListItemButton onClick={() => handleChange(index, value)}>
              {name}
            </ListItemButton>
          </ListItem>
        ))}
      </List>
    </WidgetWrapper>
  )
}

export default SideMenu