@@ -3,6 +3,8 @@ import { LuMapPin, LuMail, LuGlobe, LuTwitter, LuGithub, LuMessageSquare, LuSend
33import { ChainIcon } from './ChainIcon' ;
44import { getChainIconUrl } from '../utils/chainIcons' ;
55import { useFollowers } from '../hooks/useFollowers' ;
6+ import { ProfileSearchResult } from '@/hooks/useSearch' ;
7+ import { useProfile } from '@/hooks/useProfile' ;
68
79interface Profile {
810 name : string ;
@@ -26,11 +28,12 @@ interface Profile {
2628}
2729
2830interface SearchResultProps {
29- profile : Profile ;
31+ profile : ProfileSearchResult ;
3032}
3133
3234export function SearchResult ( { profile } : SearchResultProps ) {
3335 const { data : followersData } = useFollowers ( profile . name ) ;
36+ const { data : profileData } = useProfile ( profile . name ) ;
3437
3538 return (
3639 < div className = "bg-white rounded-lg overflow-hidden shadow-sm hover:shadow-md transition-all duration-200" >
@@ -41,11 +44,11 @@ export function SearchResult({ profile }: SearchResultProps) {
4144 >
4245 < div className = "relative h-full flex flex-col" >
4346 { /* Header/Banner image */ }
44- { profile . header || profile . records ?. header ? (
47+ { profileData ? .header || profileData ? .records ?. header ? (
4548 < div className = "w-full aspect-[3/1] overflow-hidden" >
4649 < img
47- src = { profile . header || profile . records ?. header }
48- alt = { `${ profile . display } banner` }
50+ src = { profileData . header || profileData . records ?. header }
51+ alt = { `${ profileData . display } banner` }
4952 className = "w-full h-full object-cover"
5053 />
5154 </ div >
@@ -57,38 +60,38 @@ export function SearchResult({ profile }: SearchResultProps) {
5760 < div className = "p-2 flex-1" >
5861 < div className = "flex items-start space-x-2 pr-2 pb-1 h-full" >
5962 { /* Avatar */ }
60- < div className = { `${ profile . header || profile . records ?. header ? '-mt-7' : '' } flex-shrink-0` } >
61- { profile . avatar ? (
63+ < div className = { `${ profileData ? .header || profileData ? .records ?. header ? '-mt-7' : '' } flex-shrink-0` } >
64+ { profileData ? .avatar ? (
6265 < img
63- src = { profile . avatar }
64- alt = { profile . display }
66+ src = { profileData . avatar }
67+ alt = { profileData . display }
6568 className = "h-14 w-14 rounded-full border-2 border-white shadow-md object-cover"
6669 />
6770 ) : (
6871 < div className = "h-14 w-14 rounded-full bg-gray-200 flex items-center justify-center text-gray-500 text-xl font-bold" >
69- { profile . display . charAt ( 0 ) . toUpperCase ( ) }
72+ { profileData ? .display ? .charAt ( 0 ) . toUpperCase ( ) }
7073 </ div >
7174 ) }
7275 </ div >
7376
7477 { /* Profile details */ }
7578 < div className = "flex-1 min-w-0 h-full flex flex-col" >
7679 < h3 className = "text-base font-semibold text-blue-600 truncate" >
77- { profile . display }
80+ { profileData ? .display }
7881 </ h3 >
79- { profile . address && (
82+ { profileData ? .address && (
8083 < p className = "text-xs text-gray-500 truncate" >
81- { profile . address }
84+ { profileData . address }
8285 </ p >
8386 ) }
8487 < p className = "mt-1 text-xs text-gray-600 whitespace-pre-line line-clamp-2" >
85- { profile . records ?. description || '' }
88+ { profileData ? .records ?. description || '' }
8689 </ p >
8790
8891 { /* Chain addresses */ }
89- { profile . chains && Object . keys ( profile . chains ) . length > 0 && (
92+ { profileData ? .chains && Object . keys ( profileData . chains ) . length > 0 && (
9093 < div className = "mt-1.5 flex flex-wrap gap-x-2 gap-y-1" >
91- { Object . entries ( profile . chains ) . map ( ( [ chain , address ] ) => (
94+ { Object . entries ( profileData . chains ) . map ( ( [ chain , address ] ) => (
9295 < div key = { chain } className = "flex items-center text-xs text-gray-500" title = { `${ chain . toUpperCase ( ) } : ${ address } ` } >
9396 < ChainIcon
9497 chain = { chain }
@@ -103,47 +106,47 @@ export function SearchResult({ profile }: SearchResultProps) {
103106
104107 { /* Profile metadata */ }
105108 < div className = "mt-1.5 flex flex-wrap gap-x-3 gap-y-1 text-xs text-gray-500" >
106- { profile . records ?. location && (
109+ { profileData ? .records ?. location && (
107110 < div className = "flex items-center" >
108111 < LuMapPin className = "mr-1 h-4 w-4" />
109- < span > { profile . records . location } </ span >
112+ < span > { profileData . records . location } </ span >
110113 </ div >
111114 ) }
112- { profile . records ?. email && (
115+ { profileData ? .records ?. email && (
113116 < div className = "flex items-center" >
114117 < LuMail className = "mr-1 h-4 w-4" />
115- < span > { profile . records . email } </ span >
118+ < span > { profileData . records . email } </ span >
116119 </ div >
117120 ) }
118- { profile . records ?. url && (
121+ { profileData ? .records ?. url && (
119122 < div className = "flex items-center" >
120123 < LuGlobe className = "mr-1 h-4 w-4" />
121- < span > { profile . records . url } </ span >
124+ < span > { profileData . records . url } </ span >
122125 </ div >
123126 ) }
124127 </ div >
125128
126129 { /* Social links and followers */ }
127130 < div className = "mt-1.5 flex justify-between items-center flex-1" >
128131 < div className = "flex space-x-2" >
129- { profile . records ?. [ 'com.twitter' ] && (
132+ { profileData ? .records ?. [ 'com.twitter' ] && (
130133 < div className = "text-blue-400 hover:text-blue-600" >
131- < LuTwitter className = "h-4 w-4" title = { `Twitter: ${ profile . records [ 'com.twitter' ] } ` } />
134+ < LuTwitter className = "h-4 w-4" title = { `Twitter: ${ profileData . records [ 'com.twitter' ] } ` } />
132135 </ div >
133136 ) }
134- { profile . records ?. [ 'com.github' ] && (
137+ { profileData ? .records ?. [ 'com.github' ] && (
135138 < div className = "text-gray-700 hover:text-gray-900" >
136- < LuGithub className = "h-4 w-4" title = { `GitHub: ${ profile . records [ 'com.github' ] } ` } />
139+ < LuGithub className = "h-4 w-4" title = { `GitHub: ${ profileData . records [ 'com.github' ] } ` } />
137140 </ div >
138141 ) }
139- { profile . records ?. [ 'com.discord' ] && (
142+ { profileData ? .records ?. [ 'com.discord' ] && (
140143 < div className = "text-indigo-500 hover:text-indigo-700" >
141- < LuMessageSquare className = "h-4 w-4" title = { `Discord: ${ profile . records [ 'com.discord' ] } ` } />
144+ < LuMessageSquare className = "h-4 w-4" title = { `Discord: ${ profileData . records [ 'com.discord' ] } ` } />
142145 </ div >
143146 ) }
144- { profile . records ?. [ 'org.telegram' ] && (
147+ { profileData ? .records ?. [ 'org.telegram' ] && (
145148 < div className = "text-blue-500 hover:text-blue-700" >
146- < LuSend className = "h-4 w-4" title = { `Telegram: ${ profile . records [ 'org.telegram' ] } ` } />
149+ < LuSend className = "h-4 w-4" title = { `Telegram: ${ profileData . records [ 'org.telegram' ] } ` } />
147150 </ div >
148151 ) }
149152 </ div >
0 commit comments