| 4250 |
stevensc |
1 |
/* eslint-disable react/prop-types */
|
| 5173 |
stevensc |
2 |
import React, { useEffect, useState, useRef } from 'react'
|
| 5373 |
stevensc |
3 |
import ProfileInfo from '../../../../shared/profile/edit/profile-info/ProfileInfo'
|
| 5173 |
stevensc |
4 |
import MyGroups from '../../../../shared/helpers/my-groups-helper/MyGroups'
|
|
|
5 |
import SuggestedGroupsHelper from '../../../../shared/helpers/suggested-groups-helper/SuggestedGroupsHelper'
|
| 5384 |
stevensc |
6 |
import SocialNetworks from '../../../../dashboard/components/home-section/SocialNetworks'
|
| 4250 |
stevensc |
7 |
|
| 5173 |
stevensc |
8 |
const ResponsiveNavbar = ({ show, navbarVars, LABELS }) => {
|
| 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 |
>
|
|
|
40 |
<ProfileInfo
|
|
|
41 |
{...navbarVars}
|
|
|
42 |
headerClasses="d-flex rounded-0"
|
|
|
43 |
/>
|
| 5173 |
stevensc |
44 |
<MyGroups LABELS={LABELS} suggestedClassname="d-block" />
|
| 4250 |
stevensc |
45 |
<SuggestedGroupsHelper suggestedClassname='d-block' />
|
| 5173 |
stevensc |
46 |
<SocialNetworks LABELS={LABELS} />
|
| 4250 |
stevensc |
47 |
</nav>
|
|
|
48 |
)
|
|
|
49 |
}
|
|
|
50 |
|
| 5173 |
stevensc |
51 |
export default ResponsiveNavbar
|