Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3201 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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