import React, { useRef, useState } from 'react'; import Image from 'next/image'; import { Menu } from 'primereact/menu'; import { Tooltip } from 'primereact/tooltip'; import { nip19 } from 'nostr-tools'; import { useImageProxy } from '@/hooks/useImageProxy'; import { useToast } from '@/hooks/useToast'; import UserBadges from '@/components/profile/UserBadges'; import useWindowWidth from '@/hooks/useWindowWidth'; const UserProfileCard = ({ user }) => { const [showBadges, setShowBadges] = useState(false); const menu = useRef(null); const { showToast } = useToast(); const { returnImageProxy } = useImageProxy(); const windowWidth = useWindowWidth(); const copyToClipboard = (text) => { navigator.clipboard.writeText(text); showToast("success", "Copied", "Copied to clipboard"); }; const menuItems = [ ...(user?.privkey ? [{ label: 'Copy nsec', icon: 'pi pi-key', command: () => { const privkeyBuffer = Buffer.from(user.privkey, 'hex'); copyToClipboard(nip19.nsecEncode(privkeyBuffer)); } }] : []), { label: 'Copy npub', icon: 'pi pi-user', command: () => { if (user.pubkey) { copyToClipboard(nip19.npubEncode(user?.pubkey)); } } }, { label: 'Open Nostr Profile', icon: 'pi pi-external-link', command: () => window.open(`https://nostr.com/${nip19.npubEncode(user?.pubkey)}`, '_blank') } ]; const MobileProfileCard = () => (
{nip19.npubEncode(user.pubkey)}
Joined: {new Date(user.createdAt).toLocaleDateString()}
)}{nip19.npubEncode(user.pubkey).slice(0, 12)}...
Joined: {new Date(user.createdAt).toLocaleDateString()}
)}