import React, { useRef } from 'react'; import { UserPicture } from '@growi/ui'; import { useTranslation } from 'next-i18next'; import Link from 'next/link'; import { useRipple } from 'react-use-ripple'; import { toastError } from '~/client/util/apiNotification'; import { apiv3Post } from '~/client/util/apiv3-client'; import { useCurrentUser } from '~/stores/context'; const PersonalDropdown = () => { const { t } = useTranslation(); const { data: currentUser } = useCurrentUser(); // ripple const buttonRef = useRef(null); useRipple(buttonRef, { rippleColor: 'rgba(255, 255, 255, 0.3)' }); const user = currentUser || {}; const logoutHandler = async() => { try { await apiv3Post('/logout'); window.location.reload(); } catch (err) { toastError(err); } }; return ( <> {/* Button */} {/* remove .dropdown-toggle for hide caret */} {/* See https://stackoverflow.com/a/44577512/13183572 */} {/* Menu */}
{user.name}
{user.username}
{user.email}
{ t('personal_dropdown.home') } { t('personal_dropdown.settings') }
); }; export default PersonalDropdown;