|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import Link from 'next/link' |
4 | 3 | import { useRouter } from 'next/navigation' |
| 4 | +import { useState } from 'react' |
| 5 | +import { useAccount } from 'wagmi' |
5 | 6 | import { useTranslation } from 'react-i18next' |
6 | 7 | import { ProfileCard } from 'ethereum-identity-kit' |
7 | 8 |
|
8 | 9 | import { cn } from '#/lib/utilities' |
9 | 10 | import Achievements from './components/achievements' |
10 | 11 | import FollowButton from '#/components/follow-button' |
| 12 | +import ENSRecordsModal from '#/components/ens-records-modal' |
11 | 13 | import ThreeDotMenu from './components/three-dot-menu' |
12 | 14 | import { useProfileCard } from './hooks/use-profile-card' |
13 | | -import EnsLogo from 'public/assets/icons/socials/ens.svg' |
14 | 15 | import { useEFPProfile } from '#/contexts/efp-profile-context' |
15 | 16 | import LoadingProfileCard from './components/loading-profile-card' |
16 | 17 | import type { ProfileDetailsResponse, StatsResponse } from '#/types/requests' |
@@ -53,75 +54,74 @@ const UserProfileCard: React.FC<UserProfileCardProps> = ({ |
53 | 54 | }) => { |
54 | 55 | const router = useRouter() |
55 | 56 | const { t } = useTranslation() |
| 57 | + const { address: connectedAddress } = useAccount() |
56 | 58 | const { selectedList } = useEFPProfile() |
| 59 | + const [ensRecordsOpen, setEnsRecordsOpen] = useState(false) |
57 | 60 | const { followState, profileName, isConnectedUserCard } = useProfileCard(profile) |
| 61 | + const ensRecordsName = profile?.ens?.name ?? profileName |
58 | 62 |
|
59 | 63 | return ( |
60 | 64 | <div className={cn('bg-neutral flex w-[364px] flex-col gap-4 rounded-sm pb-3', className)}> |
61 | 65 | {isLoading ? ( |
62 | 66 | <LoadingProfileCard hideFollowButton={true} className='bg-neutral' /> |
63 | 67 | ) : profile?.address ? ( |
64 | | - <ProfileCard |
65 | | - list={profileList} |
66 | | - onStatClick={({ stat }) => { |
67 | | - router.push(`/${profile.address}?tab=${stat}&ssr=false`) |
68 | | - }} |
69 | | - showFollowerState={true} |
70 | | - showFollowButton={!hideFollowButton} |
71 | | - addressOrName={profile.address} |
72 | | - onProfileClick={(addressOrName) => { |
73 | | - router.push(`/${addressOrName}?ssr=false`) |
74 | | - }} |
75 | | - selectedList={selectedList} |
76 | | - className='bg-neutral' |
77 | | - extraOptions={{ |
78 | | - openListSettings: openListSettingsModal, |
79 | | - prefetched: { |
80 | | - profile: { |
81 | | - data: profile ?? undefined, |
82 | | - isLoading: !!isLoading, |
83 | | - refetch: refetchProfile ?? (() => {}), |
| 68 | + <> |
| 69 | + <ProfileCard |
| 70 | + list={profileList} |
| 71 | + connectedAddress={connectedAddress} |
| 72 | + onStatClick={({ stat }) => { |
| 73 | + router.push(`/${profile.address}?tab=${stat}&ssr=false`) |
| 74 | + }} |
| 75 | + showFollowerState={true} |
| 76 | + showFollowButton={!hideFollowButton} |
| 77 | + addressOrName={profile.address} |
| 78 | + onProfileClick={(addressOrName) => { |
| 79 | + router.push(`/${addressOrName}?ssr=false`) |
| 80 | + }} |
| 81 | + selectedList={selectedList} |
| 82 | + className='bg-neutral' |
| 83 | + extraOptions={{ |
| 84 | + openListSettings: openListSettingsModal, |
| 85 | + onEditProfileClick: () => setEnsRecordsOpen(true), |
| 86 | + prefetched: { |
| 87 | + profile: { |
| 88 | + data: profile ?? undefined, |
| 89 | + isLoading: !!isLoading, |
| 90 | + refetch: refetchProfile ?? (() => {}), |
| 91 | + }, |
| 92 | + stats: { |
| 93 | + data: stats ?? undefined, |
| 94 | + isLoading: !!isStatsLoading, |
| 95 | + refetch: refetchStats ?? (() => {}), |
| 96 | + }, |
84 | 97 | }, |
85 | | - stats: { |
86 | | - data: stats ?? undefined, |
87 | | - isLoading: !!isStatsLoading, |
88 | | - refetch: refetchStats ?? (() => {}), |
89 | | - }, |
90 | | - }, |
91 | | - nameMenu: ( |
92 | | - <ThreeDotMenu |
93 | | - address={profile.address} |
94 | | - profileList={profileList} |
95 | | - primaryList={Number(profile.primary_list)} |
96 | | - profileName={profileName} |
97 | | - showMoreOptions={!!showMoreOptions} |
98 | | - isConnectedUserCard={isConnectedUserCard} |
99 | | - followState={followState} |
100 | | - openBlockModal={openBlockModal} |
101 | | - openQrCodeModal={openQrCodeModal} |
102 | | - openListSettingsModal={openListSettingsModal} |
103 | | - /> |
104 | | - ), |
105 | | - customFollowButton: ( |
106 | | - <div className='mt-16'> |
107 | | - {isConnectedUserCard ? ( |
108 | | - <Link href={`https://app.ens.domains/${profile.ens?.name}`} target='_blank'> |
109 | | - <button className='flex items-center gap-1 rounded-sm bg-[#0080BC] p-1.5 py-2 font-semibold text-white transition-all hover:scale-110 hover:bg-[#07A9F5]'> |
110 | | - <EnsLogo className='h-auto w-5' /> |
111 | | - <p>Edit Profile</p> |
112 | | - </button> |
113 | | - </Link> |
114 | | - ) : ( |
| 98 | + nameMenu: ( |
| 99 | + <ThreeDotMenu |
| 100 | + address={profile.address} |
| 101 | + profileList={profileList} |
| 102 | + primaryList={Number(profile.primary_list)} |
| 103 | + profileName={profileName} |
| 104 | + showMoreOptions={!!showMoreOptions} |
| 105 | + isConnectedUserCard={isConnectedUserCard} |
| 106 | + followState={followState} |
| 107 | + openBlockModal={openBlockModal} |
| 108 | + openQrCodeModal={openQrCodeModal} |
| 109 | + openListSettingsModal={openListSettingsModal} |
| 110 | + /> |
| 111 | + ), |
| 112 | + customFollowButton: isConnectedUserCard ? undefined : ( |
| 113 | + <div className='mt-16'> |
115 | 114 | <FollowButton address={profile.address} /> |
116 | | - )} |
117 | | - </div> |
118 | | - ), |
119 | | - }} |
120 | | - style={{ |
121 | | - width: '100%', |
122 | | - zIndex: 10, |
123 | | - }} |
124 | | - /> |
| 115 | + </div> |
| 116 | + ), |
| 117 | + }} |
| 118 | + style={{ |
| 119 | + width: '100%', |
| 120 | + zIndex: 10, |
| 121 | + }} |
| 122 | + /> |
| 123 | + {ensRecordsOpen && <ENSRecordsModal name={ensRecordsName} onClose={() => setEnsRecordsOpen(false)} />} |
| 124 | + </> |
125 | 125 | ) : ( |
126 | 126 | <div className={cn('relative z-10 flex flex-col rounded-sm', isRecommended ? 'bg-neutral' : 'glass-card')}> |
127 | 127 | {isRecommended ? ( |
|
0 commit comments