Rev 3201 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react';
import { Link } from 'react-router-dom';
const ListItemDropdown = ({ options = [], isShow, onSelect }) => {
if (!options.length) {
return null;
}
return (
<nav className={`nav__options-dropdown ${isShow && 'show'}`} onClick={onSelect}>
<ul>
{options.map(({ label, href, childs = [], count }, index) => {
const redirect = Boolean(childs?.length);
const to = href[0] === '/' ? href : `/${href}`;
if (label === 'Chat') return null;
return (
<li key={index}>
<Link to={to} onClick={(e) => redirect && e.preventDefault()}>
{label}
{count ? ` | ${count}` : null}
</Link>
{!!childs?.length && (
<nav className='nav__options-dropdown level_three'>
<ul>
{childs?.map((optionsChild, index) => (
<li key={index}>
<Link to={`/${optionsChild.href}`}>{optionsChild.label}</Link>
</li>
))}
</ul>
</nav>
)}
</li>
);
})}
</ul>
</nav>
);
};
export default ListItemDropdown;