diff --git a/src/routes/admin/verification/[id].tsx b/src/routes/admin/verification/[id].tsx index 714dd13..a7b0c5d 100644 --- a/src/routes/admin/verification/[id].tsx +++ b/src/routes/admin/verification/[id].tsx @@ -97,14 +97,23 @@ export default function VerificationReviewDetailPage() { }); // Real submitted profile data, from the fetched verification's `payload` field. + // A small number of older submissions accidentally stored payload as + // { roleKey, profile_data: {...} } instead of the flat field object - unwrap + // defensively so both shapes render correctly here. + const normalizedPayload = createMemo>(() => { + const raw = verif()?.payload ?? {}; + const nested = (raw as any)?.profile_data; + return (nested && typeof nested === 'object') ? nested : raw; + }); + const payloadFullName = createMemo(() => { - const payload = verif()?.payload ?? {}; + const payload = normalizedPayload() as any; const name = [payload.first_name, payload.last_name].filter(Boolean).join(' ').trim(); return name || payload.company_name || payload.full_name || '—'; }); const payloadEntries = createMemo>(() => { - const payload = verif()?.payload ?? {}; + const payload = normalizedPayload(); const skipKeys = new Set(['first_name', 'last_name', 'company_name', 'full_name', 'documents']); return Object.entries(payload).filter(([key, value]) => { if (skipKeys.has(key)) return false; @@ -365,7 +374,7 @@ export default function VerificationReviewDetailPage() {
-

Applicant

{verif()?.payload?.first_name ?? verif()?.payload?.company_name ?? '—'} {verif()?.payload?.last_name ?? ''}

+

Applicant

{(normalizedPayload() as any)?.first_name ?? (normalizedPayload() as any)?.company_name ?? '—'} {(normalizedPayload() as any)?.last_name ?? ''}

Role

{verif()?.role_key ?? roleLabel()}

Submitted

{verif()?.created_at ? new Date(verif().created_at).toLocaleDateString('en-IN') : '—'}

diff --git a/src/routes/admin/verification/index.tsx b/src/routes/admin/verification/index.tsx index 9300a6f..1d0e8a6 100644 --- a/src/routes/admin/verification/index.tsx +++ b/src/routes/admin/verification/index.tsx @@ -181,23 +181,35 @@ export default function VerificationManagementPage() { return !['COMPLETED', 'FINAL_REJECTED'].includes(status); }) .map((v: any) => { - const payload = v.payload || {}; + // Some older submissions accidentally stored payload as + // { roleKey, profile_data: {...} } instead of the flat field object - + // unwrap defensively so both shapes render correctly. + const rawPayload = v.payload || {}; + const payload = (rawPayload && typeof rawPayload.profile_data === 'object' && rawPayload.profile_data) + ? rawPayload.profile_data + : rawPayload; const rawType = String(v.type || v.case_type || '').toLowerCase(); const isJob = rawType.includes('job'); const isRequirement = rawType.includes('requirement'); - const userType = (isJob ? 'COMPANY' : (isRequirement ? 'CUSTOMER' : 'PROFESSIONAL')) as VerificationRow['userType']; - + const isCompany = String(v.role_key || '').toUpperCase() === 'COMPANY'; + const userType = (isJob ? 'COMPANY' : (isCompany ? 'COMPANY' : (isRequirement ? 'CUSTOMER' : 'PROFESSIONAL'))) as VerificationRow['userType']; + + const displayName = isCompany + ? (payload.company_name || payload.companyName) + : ([payload.first_name || payload.firstName, payload.last_name || payload.lastName].filter(Boolean).join(' ') + || payload.full_name || payload.name); + return { id: v.id, reference_number: v.reference_number || v.id, - applicantName: v.user_name || 'Applicant', - requestType: (isJob ? 'Job Approval' : (isRequirement ? 'Service Seeker Requirement' : 'Profile Approval')) as VerificationRow['requestType'], + applicantName: v.user_name || displayName || 'Applicant', + requestType: (isJob ? 'Job Approval' : (isCompany ? 'Company Approval' : (isRequirement ? 'Service Seeker Requirement' : 'Profile Approval'))) as VerificationRow['requestType'], roleLabel: toTitle(v.role_key || 'User'), submittedOn: v.created_at, status: v.status as VerificationStatus, priority: 'MEDIUM', userType, - area: payload.city || payload.area || 'Unknown', + area: payload.city || payload.area || payload.location || '—', userId: v.user_id, roleKey: v.role_key, payload, @@ -747,7 +759,7 @@ export default function VerificationManagementPage() {
{row.applicantName} - {row.area || 'Chennai'} + {row.area}
{row.roleLabel}