| 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'
|
| 4250 |
stevensc |
6 |
|
| 5173 |
stevensc |
7 |
const ResponsiveNavbar = ({ show, navbarVars, LABELS }) => {
|
| 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 |
>
|
|
|
39 |
<ProfileInfo
|
|
|
40 |
{...navbarVars}
|
|
|
41 |
headerClasses="d-flex rounded-0"
|
|
|
42 |
/>
|
| 5173 |
stevensc |
43 |
<MyGroups LABELS={LABELS} suggestedClassname="d-block" />
|
| 4250 |
stevensc |
44 |
<SuggestedGroupsHelper suggestedClassname='d-block' />
|
| 5173 |
stevensc |
45 |
<SocialNetworks LABELS={LABELS} />
|
| 4250 |
stevensc |
46 |
</nav>
|
|
|
47 |
)
|
|
|
48 |
}
|
|
|
49 |
|
| 5173 |
stevensc |
50 |
export default ResponsiveNavbar
|