import { Menu, Dropdown, Button, Space } from 'antd'; import { CaretDownOutlined, EditOutlined, LockOutlined, MessageOutlined, UserOutlined, } from '@ant-design/icons'; import { useRecoilState, useRecoilValue } from 'recoil'; import { FC, useState } from 'react'; import { useHotkeys } from 'react-hotkeys-hook'; import { Modal } from '../../ui/Modal/Modal'; import { chatVisibleToggleAtom, chatDisplayNameAtom, appStateAtom, } from '../../stores/ClientConfigStore'; import styles from './UserDropdown.module.scss'; import { NameChangeModal } from '../../modals/NameChangeModal/NameChangeModal'; import { AppStateOptions } from '../../stores/application-state'; import { AuthModal } from '../../modals/AuthModal/AuthModal'; export type UserDropdownProps = { username?: string; }; export const UserDropdown: FC = ({ username: defaultUsername = undefined }) => { const username = defaultUsername || useRecoilValue(chatDisplayNameAtom); const [showNameChangeModal, setShowNameChangeModal] = useState(false); const [showAuthModal, setShowAuthModal] = 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 } onClick={() => setShowAuthModal(true)}> Authenticate {appState.chatAvailable && ( } onClick={() => toggleChatVisibility()}> Toggle chat )} ); return (
setShowNameChangeModal(false)} > setShowAuthModal(false)} >
); };