fix: show real company/applicant data in Verification Management table and detail view
All checks were successful
build-and-release / build (push) Successful in 44s
All checks were successful
build-and-release / build (push) Successful in 44s
Applicant Name was hardcoded to 'Applicant' (backend never returns a user_name field), the Company category tab could never match anything since requestType was never set to 'Company Approval', and a class of submissions with an accidentally double-wrapped payload rendered as blank/Unknown everywhere. Derives the display name and area from the actual payload fields (with defensive unwrapping for the double-wrapped shape), and classifies company submissions correctly for tab filtering. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
fadb2c0a80
commit
1de5baeb92
2 changed files with 31 additions and 10 deletions
|
|
@ -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<Record<string, unknown>>(() => {
|
||||
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<Array<[string, unknown]>>(() => {
|
||||
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() {
|
|||
|
||||
<div style="margin-top:14px;display:grid;grid-template-columns:2fr 1fr;gap:12px">
|
||||
<div style="border:1px solid #E5E7EB;background:white;border-radius:14px;padding:14px;display:grid;grid-template-columns:1fr 1fr 1fr;gap:14px">
|
||||
<div><p style="margin:0;font-size:11px;color:#9CA3AF;text-transform:uppercase;letter-spacing:0.04em">Applicant</p><p style="margin:6px 0 0;font-size:30px;font-weight:800;color:#111827;line-height:1.1">{verif()?.payload?.first_name ?? verif()?.payload?.company_name ?? '—'} {verif()?.payload?.last_name ?? ''}</p></div>
|
||||
<div><p style="margin:0;font-size:11px;color:#9CA3AF;text-transform:uppercase;letter-spacing:0.04em">Applicant</p><p style="margin:6px 0 0;font-size:30px;font-weight:800;color:#111827;line-height:1.1">{(normalizedPayload() as any)?.first_name ?? (normalizedPayload() as any)?.company_name ?? '—'} {(normalizedPayload() as any)?.last_name ?? ''}</p></div>
|
||||
<div><p style="margin:0;font-size:11px;color:#9CA3AF;text-transform:uppercase;letter-spacing:0.04em">Role</p><p style="margin:6px 0 0;font-size:18px;font-weight:700;color:#111827">{verif()?.role_key ?? roleLabel()}</p></div>
|
||||
<div><p style="margin:0;font-size:11px;color:#9CA3AF;text-transform:uppercase;letter-spacing:0.04em">Submitted</p><p style="margin:6px 0 0;font-size:18px;font-weight:700;color:#111827">{verif()?.created_at ? new Date(verif().created_at).toLocaleDateString('en-IN') : '—'}</p></div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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() {
|
|||
<td style="padding:12px 20px">
|
||||
<div style="display:flex;flex-direction:column;gap:2px">
|
||||
<span style="font-size:14px;font-weight:600;color:#111827">{row.applicantName}</span>
|
||||
<span style="font-size:12px;color:#6B7280">{row.area || 'Chennai'}</span>
|
||||
<span style="font-size:12px;color:#6B7280">{row.area}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="padding:12px 20px;font-size:14px;color:#111827">{row.roleLabel}</td>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue