NostrProfile.tsx (1128B)
1 import { useIntl } from "react-intl"; 2 import Image from "next/image"; 3 import { nip19 } from "nostr-tools" 4 import { Profile } from "@/utils/PurpleUtils"; 5 6 export interface NostrProfileProps { 7 pubkey: string 8 profile: Profile | null 9 profileHeader: React.ReactNode 10 profileFooter: React.ReactNode 11 } 12 13 export function NostrProfile(props: NostrProfileProps) { 14 const intl = useIntl() 15 const { profile, pubkey } = props 16 const npub = nip19.npubEncode(pubkey) 17 18 return (<> 19 <div className="mt-2 mb-4 flex flex-col items-center"> 20 {props.profileHeader} 21 <div className="mt-4 flex flex-col gap-1 items-center justify-center mb-4"> 22 <Image src={profile?.picture || ("https://robohash.org/" + (pubkey))} width={64} height={64} className="rounded-full" alt={profile?.name || intl.formatMessage({ id: "purple.profile.unknown-user", defaultMessage: "Generic user avatar" })} /> 23 <div className="text-purple-100/90 font-semibold text-lg"> 24 {profile?.name || (npub.substring(0, 8) + ":" + npub.substring(npub.length - 8))} 25 </div> 26 </div> 27 {props.profileFooter} 28 </div> 29 </>) 30 }