import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { UserStats } from '@app/users/components/stats'; import { useStorage } from '@libs/storage/provider'; import { NIP05 } from '@shared/nip05'; import { useNostr } from '@utils/hooks/useNostr'; import { useProfile } from '@utils/hooks/useProfile'; import { displayNpub } from '@utils/shortenKey'; export function UserProfile({ pubkey }: { pubkey: string }) { const { db } = useStorage(); const { user } = useProfile(pubkey); const { addContact, removeContact } = useNostr(); const [followed, setFollowed] = useState(false); const followUser = (pubkey: string) => { try { addContact(pubkey); // update state setFollowed(true); } catch (error) { console.log(error); } }; const unfollowUser = (pubkey: string) => { try { removeContact(pubkey); // update state setFollowed(false); } catch (error) { console.log(error); } }; useEffect(() => { if (db.account.follows.includes(pubkey)) { setFollowed(true); } }, []); return (
{pubkey}
{followed ? ( ) : ( )} Message
{user?.name || user?.display_name || user?.displayName || 'Anon'}
{user?.nip05 ? ( ) : ( {displayNpub(pubkey, 16)} )}

{user?.about}

); }