33
44import React , { useState , useEffect } from 'react' ;
55import Image from 'next/image' ;
6+ import { useRouter } from 'next/navigation' ;
67import { SkillListing } from '@/types/skillListing' ;
7- import { BadgeCheck , Edit , Trash2 , Eye , Users , Shield , CheckCircle , Clock , XCircle } from 'lucide-react' ;
8+ import { BadgeCheck , Edit , Trash2 , Eye , Users , Shield , CheckCircle , Clock , XCircle , AlertCircle } from 'lucide-react' ;
89import { useAuth } from '@/lib/context/AuthContext' ;
910import { processAvatarUrl } from '@/utils/avatarUtils' ;
1011
@@ -19,15 +20,33 @@ interface ListingCardProps {
1920
2021const ListingCard : React . FC < ListingCardProps > = ( { listing, onDelete, onEdit } ) => {
2122 const { user } = useAuth ( ) ;
23+ const router = useRouter ( ) ;
2224 const [ isOwner , setIsOwner ] = useState ( false ) ;
2325 const [ showDetailsModal , setShowDetailsModal ] = useState ( false ) ;
26+ const [ kycStatus , setKycStatus ] = useState < string | null > ( null ) ;
2427
2528 useEffect ( ( ) => {
2629 // Check if the current user is the owner of this listing
2730 if ( user && listing ) {
2831 setIsOwner ( user . _id === listing . userId ) ;
2932 }
3033 } , [ user , listing ] ) ;
34+
35+ // Fetch KYC status for the listing user
36+ useEffect ( ( ) => {
37+ async function fetchKycStatus ( ) {
38+ try {
39+ const res = await fetch ( `/api/kyc/status?userId=${ listing . userId } ` ) ;
40+ const data = await res . json ( ) ;
41+ setKycStatus ( data . success ? data . status : null ) ;
42+ } catch ( err ) {
43+ setKycStatus ( null ) ;
44+ }
45+ }
46+ if ( listing . userId ) {
47+ fetchKycStatus ( ) ;
48+ }
49+ } , [ listing . userId ] ) ;
3150
3251 const formatDate = ( dateString : string ) => {
3352 const options : Intl . DateTimeFormatOptions = { year : 'numeric' , month : 'short' , day : 'numeric' } ;
@@ -89,7 +108,17 @@ const ListingCard: React.FC<ListingCardProps> = ({ listing, onDelete, onEdit })
89108 < div className = "flex-1 min-w-0" >
90109 < h3 className = "font-medium text-gray-800 flex items-center truncate" >
91110 < span className = "truncate" > { listing . userDetails . firstName } { listing . userDetails . lastName } </ span >
92- < BadgeCheck className = "w-4 h-4 ml-1 text-blue-500 flex-shrink-0" />
111+ { ( kycStatus === 'Accepted' || kycStatus === 'Approved' ) ? (
112+ < BadgeCheck className = "w-4 h-4 ml-1 text-blue-500 flex-shrink-0" />
113+ ) : (
114+ < button
115+ onClick = { ( ) => router . push ( '/dashboard?component=setting' ) }
116+ title = "Click to verify your account"
117+ className = "inline-flex"
118+ >
119+ < AlertCircle className = "w-4 h-4 ml-1 text-orange-500 flex-shrink-0 hover:text-orange-600 transition-colors cursor-pointer" />
120+ </ button >
121+ ) }
93122 </ h3 >
94123 < p className = "text-xs text-gray-500 truncate" >
95124 { formatDate ( listing . createdAt ) }
@@ -226,7 +255,18 @@ const ListingCard: React.FC<ListingCardProps> = ({ listing, onDelete, onEdit })
226255 < div className = "flex-1" >
227256 < h3 className = "font-semibold text-gray-800 flex items-center" >
228257 { listing . userDetails . firstName } { listing . userDetails . lastName }
229- < BadgeCheck className = "w-5 h-5 ml-2 text-blue-500" />
258+ { ( kycStatus === 'Accepted' || kycStatus === 'Approved' ) ? (
259+ < BadgeCheck className = "w-5 h-5 ml-2 text-blue-500" />
260+ ) : (
261+ < button
262+ onClick = { ( ) => router . push ( '/dashboard?component=setting' ) }
263+ className = "ml-2 px-3 py-1 text-sm bg-orange-100 text-orange-600 rounded-full flex items-center hover:bg-orange-200 transition-colors"
264+ title = "Click to verify your account"
265+ >
266+ < AlertCircle className = "w-4 h-4 mr-1" />
267+ Verify
268+ </ button >
269+ ) }
230270 </ h3 >
231271 < p className = "text-sm text-gray-500" >
232272 Posted on { formatDate ( listing . createdAt ) }
0 commit comments