import { Menu, Dropdown, Button, Space } from 'antd'; import { CaretDownOutlined, EditOutlined, LockOutlined, MessageOutlined, UserOutlined, } from '@ant-design/icons'; import { useRecoilState, useRecoilValue } from 'recoil'; import { useState } from 'react'; import Modal from '../../ui/Modal/Modal'; import { chatVisibilityAtom, chatDisplayNameAtom } from '../../stores/ClientConfigStore'; import { ChatState, ChatVisibilityState } from '../../../interfaces/application-state'; import s from './UserDropdown.module.scss'; import NameChangeModal from '../../modals/NameChangeModal'; interface Props { username?: string; chatState: ChatState; } export default function UserDropdown({ username: defaultUsername, chatState }: Props) { const [chatVisibility, setChatVisibility] = useRecoilState(chatVisibilityAtom); const username = defaultUsername || useRecoilValue(chatDisplayNameAtom); const [showNameChangeModal, setShowNameChangeModal] = useState(false); const toggleChatVisibility = () => { if (chatVisibility === ChatVisibilityState.Hidden) { setChatVisibility(ChatVisibilityState.Visible); } else { setChatVisibility(ChatVisibilityState.Hidden); } }; const handleChangeName = () => { setShowNameChangeModal(true); }; const menu = ( } onClick={() => handleChangeName()}> Change name }> Authenticate {chatState === ChatState.Available && ( } onClick={() => toggleChatVisibility()}> Toggle chat )} ); return (
setShowNameChangeModal(false)} >
); } UserDropdown.defaultProps = { username: undefined, };