@@ -10,6 +10,7 @@ import { fetchUserChatRooms } from '@/services/chatApiServices';
1010import { useAuth } from '@/lib/context/AuthContext' ;
1111import { BadgeCheck , ArrowRight , MessageCircle , Calendar , XCircle , CheckCircle , Clock , Award , BarChart3 , Target , AlertCircle } from 'lucide-react' ;
1212import { processAvatarUrl } from '@/utils/avatarUtils' ;
13+ import { getUserSkillsByUserId } from '@/services/skillServiceAdmin' ;
1314
1415interface MatchDetailsModalProps {
1516 match : SkillMatch ;
@@ -94,21 +95,56 @@ const MatchDetailsModal: React.FC<MatchDetailsModalProps> = ({ match, currentUse
9495 const [ openingChat , setOpeningChat ] = useState ( false ) ;
9596 const [ otherUserKycStatus , setOtherUserKycStatus ] = useState < string | null > ( null ) ;
9697
97- // Fetch KYC status for the other user
98+ // Skill verification state and effect (must be inside component)
99+ const [ mySkillVerified , setMySkillVerified ] = useState < boolean | null > ( null ) ;
100+ const [ otherSkillVerified , setOtherSkillVerified ] = useState < boolean | null > ( null ) ;
101+ const [ myKycStatus , setMyKycStatus ] = useState < string | null > ( null ) ;
102+ useEffect ( ( ) => {
103+ async function fetchSkillVerification ( ) {
104+ // My skill: use currentUserId
105+ if ( currentUserId && match . myDetails && match . myDetails . offeringSkill ) {
106+ const res = await getUserSkillsByUserId ( currentUserId ) ;
107+ if ( res . success && res . data ) {
108+ const found = res . data . find ( ( s : any ) => s . skillTitle === match . myDetails . offeringSkill ) ;
109+ setMySkillVerified ( found ? ! ! found . isVerified : false ) ;
110+ }
111+ }
112+ // Other user's skill
113+ if ( match . otherUser && match . otherUser . offeringSkill && match . otherUser . userId ) {
114+ const res = await getUserSkillsByUserId ( match . otherUser . userId ) ;
115+ if ( res . success && res . data ) {
116+ const found = res . data . find ( ( s : any ) => s . skillTitle === match . otherUser . offeringSkill ) ;
117+ setOtherSkillVerified ( found ? ! ! found . isVerified : false ) ;
118+ }
119+ }
120+ }
121+ fetchSkillVerification ( ) ;
122+ } , [ currentUserId , match . myDetails , match . otherUser ] ) ;
123+
124+ // Fetch KYC status for both users
98125 useEffect ( ( ) => {
99126 async function fetchKycStatus ( ) {
100127 try {
101- const res = await fetch ( `/api/kyc/status?userId=${ match . otherUser . userId } ` ) ;
102- const data = await res . json ( ) ;
103- setOtherUserKycStatus ( data . success ? data . status : null ) ;
128+ // Fetch other user's KYC status
129+ const otherRes = await fetch ( `/api/kyc/status?userId=${ match . otherUser . userId } ` ) ;
130+ const otherData = await otherRes . json ( ) ;
131+ setOtherUserKycStatus ( otherData . success ? otherData . status : null ) ;
132+
133+ // Fetch my KYC status
134+ if ( currentUserId ) {
135+ const myRes = await fetch ( `/api/kyc/status?userId=${ currentUserId } ` ) ;
136+ const myData = await myRes . json ( ) ;
137+ setMyKycStatus ( myData . success ? myData . status : null ) ;
138+ }
104139 } catch ( err ) {
105140 setOtherUserKycStatus ( null ) ;
141+ setMyKycStatus ( null ) ;
106142 }
107143 }
108144 if ( match . otherUser . userId ) {
109145 fetchKycStatus ( ) ;
110146 }
111- } , [ match . otherUser . userId ] ) ;
147+ } , [ match . otherUser . userId , currentUserId ] ) ;
112148
113149 // Format date
114150 const formatDate = ( dateString : string ) => {
@@ -363,16 +399,25 @@ const MatchDetailsModal: React.FC<MatchDetailsModalProps> = ({ match, currentUse
363399 />
364400 </ div >
365401 < div >
366- < h3 className = "font-semibold text-blue-800" > Your Profile</ h3 >
402+ < h3 className = "font-semibold text-blue-800 flex items-center" >
403+ Your Profile
404+ { ( myKycStatus === 'Accepted' || myKycStatus === 'Approved' ) ? (
405+ < BadgeCheck className = "w-4 h-4 ml-1 text-blue-500" />
406+ ) : (
407+ < AlertCircle className = "w-4 h-4 ml-1 text-orange-500" aria-label = "Not Verified" />
408+ ) }
409+ </ h3 >
367410 < p className = "text-xs text-blue-600" > Skills Exchange</ p >
368411 </ div >
369412 </ div >
370413
371414 < div className = "space-y-3" >
372415 < div className = "bg-white p-3 rounded border" >
373416 < span className = "text-xs font-medium text-green-600 uppercase tracking-wide" > Offering</ span >
374- < h4 className = "font-semibold text-gray-800 mt-1" >
417+ < h4 className = "font-semibold text-gray-800 mt-1 flex items-center gap-1 " >
375418 { match . myDetails . offeringSkill }
419+ { mySkillVerified === true && < BadgeCheck className = "w-4 h-4 text-green-500" /> }
420+ { mySkillVerified === false && < AlertCircle className = "w-4 h-4 text-orange-500" /> }
376421 </ h4 >
377422 < p className = "text-sm text-gray-600" >
378423 You'll teach this skill
@@ -441,8 +486,10 @@ const MatchDetailsModal: React.FC<MatchDetailsModalProps> = ({ match, currentUse
441486 < div className = "space-y-3" >
442487 < div className = "bg-white p-3 rounded border" >
443488 < span className = "text-xs font-medium text-green-600 uppercase tracking-wide" > They Offer</ span >
444- < h4 className = "font-semibold text-gray-800 mt-1" >
489+ < h4 className = "font-semibold text-gray-800 mt-1 flex items-center gap-1 " >
445490 { match . otherUser . offeringSkill }
491+ { otherSkillVerified === true && < BadgeCheck className = "w-4 h-4 text-green-500" /> }
492+ { otherSkillVerified === false && < AlertCircle className = "w-4 h-4 text-orange-500" /> }
446493 </ h4 >
447494 < p className = "text-sm text-gray-600" >
448495 { match . otherUser . firstName } will teach you this
0 commit comments