2024-07-31 13:53:36 +02:00
|
|
|
import { Typography } from '@mui/material'
|
2024-10-08 17:08:43 +02:00
|
|
|
import { useAppSelector } from '../hooks/store'
|
2024-07-31 13:53:36 +02:00
|
|
|
|
|
|
|
import styles from './username.module.scss'
|
|
|
|
import { AvatarIconButton } from './UserAvatarIconButton'
|
2024-02-28 21:49:44 +05:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
username: string
|
|
|
|
avatarContent: string
|
|
|
|
handleClick: (event: React.MouseEvent<HTMLElement>) => void
|
|
|
|
}
|
|
|
|
|
2024-07-31 13:53:36 +02:00
|
|
|
/**
|
|
|
|
* This component will be used for the displaying logged in user in AppBar.
|
|
|
|
* Clicking will open the menu.
|
|
|
|
*/
|
2024-02-28 21:49:44 +05:00
|
|
|
const Username = ({ username, avatarContent, handleClick }: Props) => {
|
2024-10-08 17:08:43 +02:00
|
|
|
const hexKey = useAppSelector((state) => state.auth.usersPubkey)
|
2024-04-19 14:07:18 +05:00
|
|
|
|
2024-02-28 21:49:44 +05:00
|
|
|
return (
|
2024-07-31 13:53:36 +02:00
|
|
|
<div className={styles.container}>
|
2024-02-28 21:49:44 +05:00
|
|
|
<Typography
|
2024-05-15 11:50:21 +03:00
|
|
|
variant="h6"
|
2024-02-28 21:49:44 +05:00
|
|
|
sx={{
|
2024-07-29 18:06:23 +02:00
|
|
|
fontWeight: 500,
|
|
|
|
fontSize: '14px',
|
|
|
|
color: 'var(--text-color)',
|
2024-02-28 21:49:44 +05:00
|
|
|
display: { xs: 'none', md: 'flex' }
|
|
|
|
}}
|
|
|
|
>
|
2024-07-29 18:25:32 +02:00
|
|
|
{username}
|
2024-02-28 21:49:44 +05:00
|
|
|
</Typography>
|
2024-07-31 13:53:36 +02:00
|
|
|
<AvatarIconButton
|
|
|
|
src={avatarContent}
|
|
|
|
hexKey={hexKey}
|
2024-07-29 18:06:23 +02:00
|
|
|
aria-label="account of current user"
|
|
|
|
aria-controls="menu-appbar"
|
|
|
|
aria-haspopup="true"
|
|
|
|
onClick={handleClick}
|
2024-07-31 13:53:36 +02:00
|
|
|
/>
|
2024-07-29 18:06:23 +02:00
|
|
|
</div>
|
2024-02-28 21:49:44 +05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Username
|