import { Box, IconButton, Typography, useTheme } from '@mui/material' import { useSelector } from 'react-redux' import { useNavigate } from 'react-router-dom' import { getProfileRoute } from '../routes' import { State } from '../store/rootReducer' import { hexToNpub } from '../utils' type Props = { username: string avatarContent: string handleClick: (event: React.MouseEvent) => void } const Username = ({ username, avatarContent, handleClick }: Props) => { const hexKey = useSelector((state: State) => state.auth.usersPubkey) return (
{username} user-avatar
) } export default Username type UserProps = { pubkey: string name: string image?: string } /** * This component will be used for the displaying username and profile picture. * If image is not available, robohash image will be displayed */ export const UserComponent = ({ pubkey, name, image }: UserProps) => { const theme = useTheme() const navigate = useNavigate() const npub = hexToNpub(pubkey) const roboImage = `https://robohash.org/${npub}.png?set=set3` const handleClick = (e: React.MouseEvent) => { e.stopPropagation() // navigate to user's profile navigate(getProfileRoute(pubkey)) } return ( User Image {name} ) }