import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { UserMetadata } from '@app/users/components/metadata'; import { ZapIcon } from '@shared/icons'; import { Image } from '@shared/image'; import { DEFAULT_AVATAR } from '@stores/constants'; import { useProfile } from '@utils/hooks/useProfile'; import { useSocial } from '@utils/hooks/useSocial'; import { displayNpub } from '@utils/shortenKey'; export function UserProfile({ pubkey }: { pubkey: string }) { const { user } = useProfile(pubkey); const { status, userFollows, follow, unfollow } = useSocial(); const [followed, setFollowed] = useState(false); const followUser = (pubkey: string) => { try { follow(pubkey); // update state setFollowed(true); } catch (error) { console.log(error); } }; const unfollowUser = (pubkey: string) => { try { unfollow(pubkey); // update state setFollowed(false); } catch (error) { console.log(error); } }; useEffect(() => { if (status === 'success' && userFollows) { if (userFollows.includes(pubkey)) { setFollowed(true); } } }, [status]); return (
{user?.about}