import { memo, MouseEventHandler, useCallback, useState } from 'react' import { Link, useHistory, useLocation } from 'react-router-dom' import { Button, Dropdown, DropDownProps, Menu } from 'antd' import { UserOutlined } from '@ant-design/icons' import { getUserLogin, removeUser } from '@utils/storage' import { ChangePassword } from './ChangePassword' import { PrivateMenuItemLink } from './Private/PrivateMenuItem' type UserMenuProps = Omit & { isAdmin?: boolean } export const UserMenu = memo(({ isAdmin, ...other }) => { const [isModalVisible, setIsModalVisible] = useState(false) const history = useHistory() const location = useLocation() const onChangePasswordClick: MouseEventHandler = useCallback((e) => { setIsModalVisible(true) e.preventDefault() }, []) const onChangePasswordOk = useCallback(() => { setIsModalVisible(false) history.push({ pathname: '/login', state: { from: location.pathname }}) }, [history, location]) return ( <> {isAdmin ? ( ) : ( )} Сменить пароль Выход )} > setIsModalVisible(false)} /> ) })