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