import React from 'react' import { useNavigate } from 'react-router-dom' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faUserCircle } from '@fortawesome/free-solid-svg-icons' import { useEventModel } from 'applesauce-react/hooks' import { Models } from 'applesauce-core' import { nip19 } from 'nostr-tools' interface AuthorCardProps { authorPubkey: string clickable?: boolean } const AuthorCard: React.FC = ({ authorPubkey, clickable = true }) => { const navigate = useNavigate() const profile = useEventModel(Models.ProfileModel, [authorPubkey]) const getAuthorName = () => { if (profile?.name) return profile.name if (profile?.display_name) return profile.display_name return `${authorPubkey.slice(0, 8)}...${authorPubkey.slice(-8)}` } const authorImage = profile?.picture || profile?.image const authorBio = profile?.about const handleClick = () => { if (clickable) { const npub = nip19.npubEncode(authorPubkey) navigate(`/p/${npub}`) } } return (
{authorImage ? ( {getAuthorName()} ) : ( )}
{getAuthorName()}
{authorBio && (

{authorBio}

)}
) } export default AuthorCard