import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { toast } from 'sonner'; import { useArk } from '@libs/ark'; import { NIP05 } from '@shared/nip05'; import { displayNpub } from '@utils/formater'; import { useProfile } from '@utils/hooks/useProfile'; export function UserProfile({ pubkey }: { pubkey: string }) { const { ark } = useArk(); const { user } = useProfile(pubkey); const [followed, setFollowed] = useState(false); const follow = async (pubkey: string) => { try { const add = await ark.createContact({ pubkey }); if (add) { setFollowed(true); } else { toast('You already follow this user'); } } catch (error) { console.log(error); } }; const unfollow = async (pubkey: string) => { try { const remove = await ark.deleteContact({ pubkey }); if (remove) { setFollowed(false); } } catch (error) { console.log(error); } }; useEffect(() => { if (ark.account.contacts.includes(pubkey)) { setFollowed(true); } }, []); return (