aboutsummaryrefslogtreecommitdiff
path: root/src/pages/ProfilePage/MoreMenu.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/ProfilePage/MoreMenu.tsx')
-rw-r--r--src/pages/ProfilePage/MoreMenu.tsx18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/pages/ProfilePage/MoreMenu.tsx b/src/pages/ProfilePage/MoreMenu.tsx
index bf3347b..4e681f5 100644
--- a/src/pages/ProfilePage/MoreMenu.tsx
+++ b/src/pages/ProfilePage/MoreMenu.tsx
@@ -4,10 +4,8 @@ import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
import { makeStyles } from '@material-ui/core';
-
-interface PropTypes {
- logOut: () => void;
-}
+import { useAuth } from '../../hooks/useAuth';
+import { useNavigate } from '../../hooks/useNavigate';
const ITEM_HEIGHT = 48;
@@ -19,15 +17,23 @@ const useStyles = makeStyles({
}
});
-const MoreMenu: React.FC<PropTypes> = ({ logOut }) => {
+const MoreMenu: React.FC = () => {
const classes = useStyles();
const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null);
+ const { logout } = useAuth();
+ const { navigate } = useNavigate();
+
const open = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};
+ const handleLogout = () => {
+ logout();
+ navigate('auth');
+ };
+
const handleClose = () => {
setAnchorEl(null);
};
@@ -56,7 +62,7 @@ const MoreMenu: React.FC<PropTypes> = ({ logOut }) => {
}
}}
>
- <MenuItem onClick={logOut}>Log out</MenuItem>
+ <MenuItem onClick={handleLogout}>Log out</MenuItem>
</Menu>
</div>
</div>