diff --git a/src/components/username.tsx b/src/components/username.tsx
index 928d0c6..387a4c6 100644
--- a/src/components/username.tsx
+++ b/src/components/username.tsx
@@ -1,6 +1,9 @@
-import { Typography, IconButton } from '@mui/material'
+import { Typography, IconButton, Box, useTheme } from '@mui/material'
import { useSelector } from 'react-redux'
import { State } from '../store/rootReducer'
+import { hexToNpub } from '../utils'
+import { Link } from 'react-router-dom'
+import { getProfileRoute } from '../routes'
type Props = {
username: string
@@ -44,3 +47,43 @@ const Username = ({ username, avatarContent, handleClick }: Props) => {
}
export default Username
+
+type UserProps = {
+ pubkey: string
+ name: string
+ image?: string
+}
+
+export const UserComponent = ({ pubkey, name, image }: UserProps) => {
+ const theme = useTheme()
+
+ const npub = hexToNpub(pubkey)
+ const roboImage = `https://robohash.org/${npub}.png?set=set3`
+
+ return (
+
+
+
+
+ {name}
+
+
+
+ )
+}
diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx
index 6db90a3..2f9fc67 100644
--- a/src/pages/create/index.tsx
+++ b/src/pages/create/index.tsx
@@ -18,18 +18,22 @@ import {
Tooltip,
Typography
} from '@mui/material'
+import JSZip from 'jszip'
import { MuiFileInput } from 'mui-file-input'
import { useEffect, useState } from 'react'
-import { Link, useNavigate } from 'react-router-dom'
+import { useSelector } from 'react-redux'
+import { useNavigate } from 'react-router-dom'
+import { toast } from 'react-toastify'
import { LoadingSpinner } from '../../components/LoadingSpinner'
+import { UserComponent } from '../../components/username'
import { MetadataController, NostrController } from '../../controllers'
-import { appPrivateRoutes, getProfileRoute } from '../../routes'
+import { appPrivateRoutes } from '../../routes'
+import { State } from '../../store/rootReducer'
import { ProfileMetadata, User, UserRole } from '../../types'
import {
encryptArrayBuffer,
generateEncryptionKey,
getHash,
- getRoboHashPicture,
hexToNpub,
pubToHex,
queryNip05,
@@ -39,10 +43,6 @@ import {
uploadToFileStorage
} from '../../utils'
import styles from './style.module.scss'
-import { toast } from 'react-toastify'
-import JSZip from 'jszip'
-import { useSelector } from 'react-redux'
-import { State } from '../../store/rootReducer'
export const CreatePage = () => {
const navigate = useNavigate()
@@ -489,15 +489,6 @@ const DisplayUser = ({
})
}, [users])
- /**
- * Use robohash if any of the users images fail to load
- * @param event img tag onError event
- * @param pubkey of the user
- */
- const imageLoadError = (event: any, pubkey: string) => {
- event.target.src = getRoboHashPicture(pubkey)
- }
-
return (
@@ -511,33 +502,18 @@ const DisplayUser = ({
{users.map((user, index) => {
const userMeta = metadata[user.pubkey]
- const npub = hexToNpub(user.pubkey)
- const roboUrl = `https://robohash.org/${npub}.png?set=set3`
return (
-
- {
- imageLoadError(event, user.pubkey)
- }}
- src={userMeta?.picture || roboUrl}
- alt="Profile Image"
- className="profile-image"
- style={{
- borderWidth: '3px',
- borderStyle: 'solid',
- borderColor: `#${user.pubkey.substring(0, 6)}`
- }}
- />
-
-
- {userMeta?.display_name ||
- userMeta?.name ||
- shorten(npub)}
-
-
-
+