From 5e40fd793d8d86d5790e3f6bf4a7e2d0e7fa7083 Mon Sep 17 00:00:00 2001 From: Fedor Katurov <gotham48@gmail.com> Date: Wed, 27 Jul 2022 18:43:31 +0700 Subject: [PATCH] cleared profile sidebar --- .../profile/ProfileSidebarMenu/index.tsx | 26 +++++++++++-------- .../sidebars/ProfileSidebar/index.tsx | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/containers/profile/ProfileSidebarMenu/index.tsx b/src/containers/profile/ProfileSidebarMenu/index.tsx index e7a4884c..dadcf52f 100644 --- a/src/containers/profile/ProfileSidebarMenu/index.tsx +++ b/src/containers/profile/ProfileSidebarMenu/index.tsx @@ -1,14 +1,17 @@ -import React, { VFC } from 'react'; +import React, { useCallback, VFC } from 'react'; import classNames from 'classnames'; import { Filler } from '~/components/containers/Filler'; import { Group } from '~/components/containers/Group'; import { Button } from '~/components/input/Button'; +import { Icon } from '~/components/input/Icon'; +import { MenuButton, MenuItemWithIcon } from '~/components/menu'; import { VerticalMenu } from '~/components/menu/VerticalMenu'; import { useStackContext } from '~/components/sidebar/SidebarStack'; import { ProfileSidebarHead } from '~/containers/profile/ProfileSidebarHead'; import { ProfileStats } from '~/containers/profile/ProfileStats'; +import { useAuth } from '~/hooks/auth/useAuth'; import markdown from '~/styles/common/markdown.module.scss'; import styles from './styles.module.scss'; @@ -18,8 +21,14 @@ interface ProfileSidebarMenuProps { } const ProfileSidebarMenu: VFC<ProfileSidebarMenuProps> = ({ onClose }) => { + const { logout } = useAuth(); const { setActiveTab } = useStackContext(); + const onLogout = useCallback(() => { + logout(); + onClose(); + }, [onClose]); + return ( <div className={styles.wrap}> <div> @@ -30,8 +39,6 @@ const ProfileSidebarMenu: VFC<ProfileSidebarMenuProps> = ({ onClose }) => { <Group> <VerticalMenu className={styles.menu}> <VerticalMenu.Item onClick={() => setActiveTab(0)}>Настройки</VerticalMenu.Item> - <VerticalMenu.Item onClick={() => setActiveTab(1)}>Заметки</VerticalMenu.Item> - <VerticalMenu.Item onClick={() => setActiveTab(2)}>Удалённые посты</VerticalMenu.Item> </VerticalMenu> <div className={styles.stats}> @@ -40,14 +47,11 @@ const ProfileSidebarMenu: VFC<ProfileSidebarMenuProps> = ({ onClose }) => { </Group> </Filler> - <Group className={styles.buttons}> - <Button round onClick={onClose} color="outline"> - Выйти - </Button> - - <Button round onClick={onClose} color="outline-white"> - Закрыть - </Button> + <Group className={styles.buttons} horizontal> + <Filler /> + <MenuButton icon={<Button color="link"><Icon icon="dots-vertical" size={24} /></Button>} position="top-end"> + <MenuItemWithIcon onClick={onLogout}>Выйти</MenuItemWithIcon> + </MenuButton> </Group> </div> ); diff --git a/src/containers/sidebars/ProfileSidebar/index.tsx b/src/containers/sidebars/ProfileSidebar/index.tsx index 8aad811b..4e17fd44 100644 --- a/src/containers/sidebars/ProfileSidebar/index.tsx +++ b/src/containers/sidebars/ProfileSidebar/index.tsx @@ -15,7 +15,7 @@ interface ProfileSidebarProps extends DialogComponentProps { const ProfileSidebar: VFC<ProfileSidebarProps> = ({ onRequestClose }) => { return ( <SidebarWrapper onClose={onRequestClose}> - <SidebarStack> + <SidebarStack initialTab={0}> <SidebarStackCard headerFeature="close" title="Профиль" onBackPress={onRequestClose}> <ProfileSidebarMenu onClose={onRequestClose} /> </SidebarStackCard>