Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5399 | Rev 5461 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
4250 stevensc 1
/* eslint-disable react/prop-types */
5173 stevensc 2
import React, { useEffect, useState, useRef } from 'react'
3
import SuggestedGroupsHelper from '../../../../shared/helpers/suggested-groups-helper/SuggestedGroupsHelper'
5384 stevensc 4
import SocialNetworks from '../../../../dashboard/components/home-section/SocialNetworks'
5385 stevensc 5
import ProfileInfo from '../../../../dashboard/components/home-section/ProfileInfo'
5409 stevensc 6
import SuggestWidget from '../../../../shared/helpers/my-groups-helper/SuggestWidget'
4250 stevensc 7
 
5399 stevensc 8
const ResponsiveNavbar = ({ show, navbarVars }) => {
4250 stevensc 9
  // const { authorization } = props.companyVars
10
  //  const {allowProfile, allowFollower, allowUser, allowFeed, allowJob, allowCompany, allowSetting} = authorization
11
 
5173 stevensc 12
  const [shouldRender, setShouldRender] = useState(show)
4250 stevensc 13
  const responsiveNavbar = useRef()
14
 
15
  const handleUnmount = () => !show && setShouldRender(false)
16
 
17
  useEffect(() => {
18
    if (show) return setShouldRender(show)
5173 stevensc 19
  }, [show])
4250 stevensc 20
 
21
  useEffect(() => {
22
    const handleClickOutside = (event) => {
23
      if (responsiveNavbar.current && !responsiveNavbar.current.contains(event.target)) {
24
        setShouldRender(false)
25
      }
26
    }
5173 stevensc 27
    document.addEventListener('mousedown', handleClickOutside)
4250 stevensc 28
 
29
    return () => {
5173 stevensc 30
      document.removeEventListener('mousedown', handleClickOutside)
31
    }
32
  }, [responsiveNavbar])
4250 stevensc 33
 
34
  return (
35
    <nav
36
      className={`responsiveNavbar ${shouldRender ? 'slideIn' : 'slideOut'} p-0`}
37
      onAnimationEnd={handleUnmount}
38
      ref={responsiveNavbar}
39
    >
5399 stevensc 40
      <ProfileInfo {...navbarVars}/>
5409 stevensc 41
      <SuggestWidget />
4250 stevensc 42
      <SuggestedGroupsHelper suggestedClassname='d-block' />
5399 stevensc 43
      <SocialNetworks />
4250 stevensc 44
    </nav>
45
  )
46
}
47
 
5173 stevensc 48
export default ResponsiveNavbar