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 { useHotkeys } from 'react-hotkeys-hook'; import Modal from '../../ui/Modal/Modal'; import { chatVisibleToggleAtom, chatDisplayNameAtom, appStateAtom, } from '../../stores/ClientConfigStore'; import s from './UserDropdown.module.scss'; import NameChangeModal from '../../modals/NameChangeModal'; import { AppStateOptions } from '../../stores/application-state'; interface Props { username?: string; } export default function UserDropdown({ username: defaultUsername }: Props) { const username = defaultUsername || useRecoilValue(chatDisplayNameAtom); const [showNameChangeModal, setShowNameChangeModal] = useState(false); const [chatToggleVisible, setChatToggleVisible] = useRecoilState(chatVisibleToggleAtom); const appState = useRecoilValue(appStateAtom); const toggleChatVisibility = () => { setChatToggleVisible(!chatToggleVisible); }; const handleChangeName = () => { setShowNameChangeModal(true); }; // Register keyboard shortcut for the space bar to toggle playback useHotkeys( 'c', toggleChatVisibility, { enableOnContentEditable: false, }, [chatToggleVisible], ); const menu = ( } onClick={() => handleChangeName()}> Change name }> Authenticate {appState.chatAvailable && ( } onClick={() => toggleChatVisibility()}> Toggle chat )} ); return (
setShowNameChangeModal(false)} >
); } UserDropdown.defaultProps = { username: undefined, };