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