diff --git a/src/app/dashboard/users/[id]/page.tsx b/src/app/dashboard/users/[id]/page.tsx index 94c60c7..cb466da 100644 --- a/src/app/dashboard/users/[id]/page.tsx +++ b/src/app/dashboard/users/[id]/page.tsx @@ -11,6 +11,7 @@ import { AgentType, VerificationStatus, VerificationDocument, + VerificationHistoryEntry, } from '@/services'; export default function UserDetailPage() { @@ -34,6 +35,7 @@ export default function UserDetailPage() { const [isLoadingDocuments, setIsLoadingDocuments] = useState(false); const [verificationNote, setVerificationNote] = useState(''); const [isUpdatingVerification, setIsUpdatingVerification] = useState(false); + const [verificationHistory, setVerificationHistory] = useState([]); // Helper function to check if avatar is an S3 key const isS3Key = (avatar: string | null | undefined): boolean => { @@ -50,6 +52,7 @@ export default function UserDetailPage() { useEffect(() => { if (user && user.role === 'AGENT') { fetchVerificationDocuments(); + fetchVerificationHistory(); } }, [user?.id, user?.role]); @@ -131,6 +134,15 @@ export default function UserDetailPage() { } }; + const fetchVerificationHistory = async () => { + try { + const history = await usersService.getVerificationHistory(userId); + setVerificationHistory(history); + } catch { + // History may not exist yet + } + }; + const handleVerification = async (status: VerificationStatus) => { if (!user) return; @@ -149,8 +161,9 @@ export default function UserDetailPage() { : 'Agent verification rejected' ); setVerificationNote(''); - // Refresh user data + // Refresh user data and history await fetchUser(); + await fetchVerificationHistory(); // Clear success message after 3 seconds setTimeout(() => setUpdateSuccess(''), 3000); } catch (err) { @@ -763,6 +776,44 @@ export default function UserDetailPage() { )} + + {/* Verification History */} + {verificationHistory.length > 0 && ( +
+

Verification History

+
+ {verificationHistory.map((entry) => ( +
+
+
+
+ + {entry.status.replace('_', ' ')} + + + {new Date(entry.createdAt).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', hour: '2-digit', minute: '2-digit' })} + +
+ {entry.note && ( +

{entry.note}

+ )} + {entry.admin && ( +

By: {entry.admin.email}

+ )} +
+
+ ))} +
+
+ )}
)} diff --git a/src/services/index.ts b/src/services/index.ts index d4029c2..f19dd42 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -20,6 +20,7 @@ export type { UserFilters, VerificationStatus, VerificationDocument, + VerificationHistoryEntry, AgentProfileDetails, } from './users.service'; diff --git a/src/services/users.service.ts b/src/services/users.service.ts index 7838853..9277bac 100644 --- a/src/services/users.service.ts +++ b/src/services/users.service.ts @@ -150,6 +150,21 @@ class UsersService { }>>(`${this.basePath}/${userId}/verification`, data); return response.data.data; } + + async getVerificationHistory(userId: string): Promise { + const response = await api.get>(`${this.basePath}/${userId}/verification-history`); + return response.data.data; + } +} + +export interface VerificationHistoryEntry { + id: string; + agentProfileId: string; + status: VerificationStatus; + note: string | null; + adminId: string | null; + createdAt: string; + admin: { id: string; email: string } | null; } export const usersService = new UsersService();