//import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import React, { useState } from 'react'; import { DropdownItem, DropdownMenu, DropdownToggle, Dropdown } from 'reactstrap'; import { useAuth } from '../../context/UserAuth'; import JKProfileAvatar from '../profile/JKProfileAvatar'; import { useCookies } from 'react-cookie'; import { useHistory } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; // import useUserProfile from '../../hooks/useUserProfile'; import { useAppData } from '../../context/AppDataContext'; const ProfileDropdown = () => { const { t } = useTranslation(); const [dropdownOpen, setDropdownOpen] = useState(false); const toggle = () => setDropdownOpen(prevState => !prevState); const { isAuthenticated, currentUser, setCurrentUser, logout, currentUserProfile } = useAuth(); const [cookies, setCookie, removeCookie] = useCookies(['remember_token']); const history = useHistory(); // const { photoUrl } = useUserProfile(currentUser); const { appData } = useAppData(); const { currentUserPhotoUrl } = appData; const handleLogout = async event => { event.preventDefault(); removeCookie('remember_token', { domain: `.${process.env.REACT_APP_ORIGIN}` }); setCurrentUser(null); await logout(); window.location.href = "/auth/login"; }; return ( <> {isAuthenticated && ( { // let windowWidth = window.innerWidth; // windowWidth > 992 && setDropdownOpen(true); // }} // onMouseLeave={() => { // let windowWidth = window.innerWidth; // windowWidth > 992 && setDropdownOpen(false); // }} > {} {/* {currentUser && currentUser.name} */}
{/* My Profile */} {t('signout', { ns: 'auth' })}
)} ); }; export default ProfileDropdown;