From 1a9d1f6a0f411c6ff1915e83fad0f6a005d103c1 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Tue, 31 Mar 2026 22:39:02 +0530 Subject: [PATCH] fix --- src/app/dashboard/users/[id]/page.tsx | 80 +++++++++++++++++++++++++++ src/services/index.ts | 1 + src/services/users.service.ts | 15 +++++ 3 files changed, 96 insertions(+) diff --git a/src/app/dashboard/users/[id]/page.tsx b/src/app/dashboard/users/[id]/page.tsx index 4c21e3e..f166a89 100644 --- a/src/app/dashboard/users/[id]/page.tsx +++ b/src/app/dashboard/users/[id]/page.tsx @@ -12,6 +12,7 @@ import { VerificationStatus, VerificationDocument, VerificationHistoryEntry, + AgentFieldValue, } from '@/services'; export default function UserDetailPage() { @@ -36,6 +37,7 @@ export default function UserDetailPage() { const [verificationNote, setVerificationNote] = useState(''); const [isUpdatingVerification, setIsUpdatingVerification] = useState(false); const [verificationHistory, setVerificationHistory] = useState([]); + const [agentFieldValues, setAgentFieldValues] = useState([]); // Helper function to check if avatar is an S3 key const isS3Key = (avatar: string | null | undefined): boolean => { @@ -53,6 +55,9 @@ export default function UserDetailPage() { if (user && user.role === 'AGENT') { fetchVerificationDocuments(); fetchVerificationHistory(); + if (user.agentProfile?.id) { + fetchAgentFieldValues(user.agentProfile.id); + } } }, [user?.id, user?.role]); @@ -143,6 +148,15 @@ export default function UserDetailPage() { } }; + const fetchAgentFieldValues = async (agentProfileId: string) => { + try { + const values = await usersService.getAgentFieldValues(agentProfileId); + setAgentFieldValues(values); + } catch { + // Field values may not exist + } + }; + const handleVerification = async (status: VerificationStatus) => { if (!user) return; @@ -578,6 +592,41 @@ export default function UserDetailPage() { )} + {/* Agent Profile Data */} + {agentFieldValues.length > 0 && ( +
+

Profile Data

+
+ {Object.entries( + agentFieldValues + .filter((fv) => fv.sectionSlug !== 'upload-documents') + .reduce((acc, fv) => { + if (!acc[fv.sectionName]) acc[fv.sectionName] = []; + acc[fv.sectionName].push(fv); + return acc; + }, {} as Record) + ).map(([sectionName, fields]) => ( +
+

{sectionName}

+
+ {fields.map((fv) => ( +
+ {fv.fieldName}: + + {fv.value === null || fv.value === undefined ? '-' : + Array.isArray(fv.value) ? fv.value.map((v: any) => typeof v === 'object' ? (v.label || v.name || JSON.stringify(v)) : String(v)).join(', ') : + typeof fv.value === 'object' ? JSON.stringify(fv.value) : + String(fv.value)} + +
+ ))} +
+
+ ))} +
+
+ )} + {/* Uploaded Documents */}

Uploaded Documents

@@ -807,6 +856,37 @@ export default function UserDetailPage() { {entry.admin && (

By: {entry.admin.email}

)} + {entry.submittedData && ( +
+ View Submitted Data +
+ {entry.submittedData.firstName && ( +

Name: {entry.submittedData.firstName} {entry.submittedData.lastName}

+ )} + {entry.submittedData.email && ( +

Email: {entry.submittedData.email}

+ )} + {entry.submittedData.phone && ( +

Phone: {entry.submittedData.phone}

+ )} + {entry.submittedData.agentType && ( +

Type: {entry.submittedData.agentType}

+ )} + {entry.submittedData.sections && Object.entries(entry.submittedData.sections).map(([sectionSlug, sectionData]: [string, any]) => ( +
+

{sectionData._name || sectionSlug}

+ {Object.entries(sectionData).filter(([k]) => k !== '_name').map(([fieldSlug, fieldData]: [string, any]) => ( +

+ {fieldData.name || fieldSlug}:{' '} + {typeof fieldData.value === 'object' ? JSON.stringify(fieldData.value) : String(fieldData.value ?? '-')} +

+ ))} +
+ ))} +

Captured: {new Date(entry.submittedData.capturedAt).toLocaleString()}

+
+
+ )}
))} diff --git a/src/services/index.ts b/src/services/index.ts index 7d1217b..5525238 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -22,6 +22,7 @@ export type { VerificationDocument, VerificationHistoryEntry, AgentProfileDetails, + AgentFieldValue, } from './users.service'; // Agent Types Service diff --git a/src/services/users.service.ts b/src/services/users.service.ts index 24c307e..a5a84dc 100644 --- a/src/services/users.service.ts +++ b/src/services/users.service.ts @@ -156,6 +156,20 @@ class UsersService { const response = await api.get>(`${this.basePath}/${userId}/verification-history`); return response.data.data; } + + async getAgentFieldValues(agentProfileId: string): Promise { + const response = await api.get>(`/agents/${agentProfileId}/field-values`); + return response.data.data.fieldValues; + } +} + +export interface AgentFieldValue { + fieldSlug: string; + fieldName: string; + fieldType: string; + sectionSlug: string; + sectionName: string; + value: unknown; } export interface VerificationHistoryEntry { @@ -166,6 +180,7 @@ export interface VerificationHistoryEntry { adminId: string | null; createdAt: string; admin: { id: string; email: string } | null; + submittedData: Record | null; } export const usersService = new UsersService();