Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7273 | 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 }) => {
  if (!options.length) return null

  return (
    <nav className={`nav__options-dropdown ${isShow && 'show'}`}>
      <ul>
        {options.map(({ label, href, childs = [], count }, index) => {
          const redirect = Boolean(childs?.length)
          const to = href[0] === '/' ? href : `/${href}`

          return (
            <li key={index}>
              <Link to={to} onClick={(e) => redirect && e.preventDefault()}>
                {label}
                {Boolean(count) && ` | ${count}`}
              </Link>
              {Boolean(childs?.length) && (
                <nav className="navigation-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