import { useEffect, useRef } from "react"; import { locationService, userService } from "../services"; import showAboutSiteDialog from "./AboutSiteDialog"; import "../less/menu-btns-popup.less"; interface Props { shownStatus: boolean; setShownStatus: (status: boolean) => void; } const MenuBtnsPopup: React.FC = (props: Props) => { const { shownStatus, setShownStatus } = props; const popupElRef = useRef(null); useEffect(() => { if (shownStatus) { const handleClickOutside = (event: MouseEvent) => { if (!popupElRef.current?.contains(event.target as Node)) { event.stopPropagation(); } setShownStatus(false); }; window.addEventListener("click", handleClickOutside, { capture: true, once: true, }); } }, [shownStatus]); const handleMyAccountBtnClick = () => { locationService.pushHistory("/setting"); }; const handleMemosTrashBtnClick = () => { locationService.pushHistory("/trash"); }; const handleAboutBtnClick = () => { showAboutSiteDialog(); }; const handleSignOutBtnClick = async () => { await userService.doSignOut(); locationService.replaceHistory("/signin"); window.location.reload(); }; return (
); }; export default MenuBtnsPopup;