Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5266 | Rev 6245 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5266 Rev 6244
Línea 11... Línea 11...
11
  title = '',
11
  title = '',
12
  url = '',
12
  url = '',
13
  childs = [],
13
  childs = [],
14
  ajaxRequest = 0,
14
  ajaxRequest = 0,
15
  isMobile = false,
15
  isMobile = false,
16
  badgeCount = 0
16
  badgeCount = 0,
17
}) => {
17
}) => {
18
  const [displayMenu, setDisplayMenu] = useState(false)
18
  const [displayMenu, setDisplayMenu] = useState(false)
19
  const menu = useRef(null)
19
  const menu = useRef(null)
20
  const outsideClick = useOutsideClick(menu)
20
  const outsideClick = useOutsideClick(menu)
Línea 24... Línea 24...
24
  }
24
  }
Línea 25... Línea 25...
25
 
25
 
26
  const handleAjaxRequest = async () => {
26
  const handleAjaxRequest = async () => {
27
    try {
27
    try {
-
 
28
      const { data } = await axios.get(url)
28
      const { data } = await axios.get(url)
29
      if (data.success) {
-
 
30
        setTimeout(() => window.open(data.data, '_blank'), 500)
29
      if (data.success) window.open(data.data, '_backend')
31
      }
30
    } catch (error) {
32
    } catch (error) {
31
      console.log('>>: error > ', error)
33
      console.log('>>: error > ', error)
32
    }
34
    }
Línea 33... Línea 35...
33
  }
35
  }
34
 
36
 
35
  useLayoutEffect(() => {
37
  useLayoutEffect(() => {
Línea 36... Línea 38...
36
    if (outsideClick) setDisplayMenu(false)
38
    if (outsideClick) setDisplayMenu(false)
37
  }, [outsideClick])
39
  }, [outsideClick])
38
 
40
 
39
  return (
41
  return (
40
        <li ref={menu} className={!isMobile && 'd-none d-lg-block'}>
42
    <li ref={menu} className={!isMobile && 'd-none d-lg-block'}>
-
 
43
      <a
-
 
44
        href={`/${url}`}
41
            <a
45
        className={`header__option ${isMobile && 'mobile'} ${
42
                href={`/${url}`}
46
          displayMenu && 'active'
43
                className={`header__option ${isMobile && 'mobile'} ${displayMenu && 'active'}`}
47
        }`}
44
                onClick={(e) => {
48
        onClick={(e) => {
45
                  if (ajaxRequest) {
49
          if (ajaxRequest) {
46
                    e.preventDefault()
50
            e.preventDefault()
47
                    handleAjaxRequest()
51
            handleAjaxRequest()
48
                  }
52
          }
49
                  if (childs.length) {
53
          if (childs.length) {
50
                    e.preventDefault()
54
            e.preventDefault()
51
                    handleClick()
55
            handleClick()
52
                  }
56
          }
53
                }}
57
        }}
54
                target='framename'
58
        target="framename"
-
 
59
      >
55
            >
60
        {Icon && <Icon className="header__option-icon" />}
-
 
61
        <span>{title}</span>
-
 
62
        <span
56
                {Icon && <Icon className="header__option-icon" />}
63
          className={`badge ${badgeCount ? 'd-block' : 'd-none'}`}
57
                <span>{title}</span>
64
          style={{ top: '10px' }}
58
                <span className={`badge ${badgeCount ? 'd-block' : 'd-none'}`} style={{ top: '10px' }}>
65
        >
59
                    {badgeCount}
66
          {badgeCount}
60
                </span>
67
        </span>
61
            </a>
68
      </a>
62
            <ListItemDropdown isShow={displayMenu} options={childs} />
69
      <ListItemDropdown isShow={displayMenu} options={childs} />
Línea 63... Línea 70...
63
        </li>
70
    </li>