import { memo, MouseEventHandler, useCallback, useState } from 'react' import { useNavigate, useLocation } from 'react-router-dom' import { Button, Dropdown, DropDownProps } from 'antd' import { UserOutlined } from '@ant-design/icons' import { getUserLogin, removeUser } from '@utils' import { ChangePassword } from './ChangePassword' import { PrivateMenu } from './Private' import AdminPanel from '@pages/AdminPanel' type UserMenuProps = Omit & { isAdmin?: boolean } export const UserMenu = memo(({ isAdmin, ...other }) => { const [isModalVisible, setIsModalVisible] = useState(false) const navigate = useNavigate() const location = useLocation() const onChangePasswordClick: MouseEventHandler = useCallback((e) => { setIsModalVisible(true) e.preventDefault() }, []) const onChangePasswordOk = useCallback(() => { setIsModalVisible(false) navigate('/login', { state: { from: location.pathname }}) }, [navigate, location]) return ( <> {isAdmin ? ( ) : ( )} )} > setIsModalVisible(false)} /> ) })