Proyectos de Subversion LeadersLinked - SPA

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3201 stevensc 1
import React from 'react'
2
import { Link } from 'react-router-dom'
3
 
4
const ListItemDropdown = ({ options = [], isShow, onSelect }) => {
5
  if (!options.length) {
6
    return null
7
  }
8
 
9
  return (
10
    <nav
11
      className={`nav__options-dropdown ${isShow && 'show'}`}
12
      onClick={onSelect}
13
    >
14
      <ul>
15
        {options.map(({ label, href, childs = [], count }, index) => {
16
          const redirect = Boolean(childs?.length)
17
          const to = href[0] === '/' ? href : `/${href}`
18
 
19
          if (label === 'Chat') return null
20
 
21
          return (
22
            <li key={index}>
23
              <Link to={to} onClick={(e) => redirect && e.preventDefault()}>
24
                {label}
25
                {count ? ` | ${count}` : null}
26
              </Link>
27
              {!!childs?.length && (
28
                <nav className='nav__options-dropdown level_three'>
29
                  <ul>
30
                    {childs?.map((optionsChild, index) => (
31
                      <li key={index}>
32
                        <Link to={`/${optionsChild.href}`}>
33
                          {optionsChild.label}
34
                        </Link>
35
                      </li>
36
                    ))}
37
                  </ul>
38
                </nav>
39
              )}
40
            </li>
41
          )
42
        })}
43
      </ul>
44
    </nav>
45
  )
46
}
47
 
48
export default ListItemDropdown