import { useChat } from '@/providers/ChatProvider' import { useNostr } from '@/providers/NostrProvider' import { useFetchProfile } from '@/hooks/useFetchProfile' import { useSecondaryPage } from '@/PageManager' import { Pubkey } from '@/domain' import { X, ExternalLink, MessageSquare, ShieldPlus, UserMinus, Ban, Copy, Check } from 'lucide-react' import { useState } from 'react' import { Button } from '../ui/button' export default function UserProfileModal({ pubkeyHex, onClose }: { pubkeyHex: string onClose: () => void }) { const { profile } = useFetchProfile(pubkeyHex) const { pubkey } = useNostr() const { currentChannel, isOwnerOrMod, addMod, removeMember, blockUser, channelMods } = useChat() const { push } = useSecondaryPage() const [copied, setCopied] = useState(false) const pk = Pubkey.tryFromString(pubkeyHex) const npub = pk?.npub || '' const displayName = profile?.username || pk?.formatNpub(8) || pubkeyHex.slice(0, 12) const isOwner = currentChannel?.creator === pubkeyHex const isMod = channelMods.includes(pubkeyHex) const isSelf = pubkeyHex === pubkey const handleCopy = () => { navigator.clipboard.writeText(npub) setCopied(true) setTimeout(() => setCopied(false), 1500) } return (
e.stopPropagation()} > {/* Banner */} {profile?.banner ? (
) : (
)} {/* Avatar + name */}
{profile?.avatar ? ( ) : (
)}
{displayName} {isOwner && (owner)} {isMod && !isOwner && (mod)}
{profile?.about && (

{profile.about}

)} {/* Actions */}
{!isSelf && ( )}
{/* Mod actions */} {isOwnerOrMod && !isSelf && !isOwner && (
{!isMod && ( )}
)}
) }