From f30769d73a9edd908126ff6e0bdd07de4f8f36a4 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Thu, 29 Jan 2026 00:02:45 +0530 Subject: [PATCH] feat: Update document download logic to use `id` as a fallback for the S3 key and refine the `VerificationDocument` interface. --- src/app/dashboard/users/[id]/page.tsx | 9 ++++++++- src/services/users.service.ts | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/dashboard/users/[id]/page.tsx b/src/app/dashboard/users/[id]/page.tsx index f5c1c6f..603daf0 100644 --- a/src/app/dashboard/users/[id]/page.tsx +++ b/src/app/dashboard/users/[id]/page.tsx @@ -109,7 +109,14 @@ export default function UserDetailPage() { const docsWithUrls = await Promise.all( docs.map(async (doc) => { try { - const url = await uploadService.getPresignedDownloadUrl(doc.key); + // The S3 key is stored in 'id' field from the upload service + // or in 'key' field if explicitly set. Fall back to id if key is missing. + const fileKey = doc.key || doc.id; + if (!fileKey || fileKey.startsWith('http')) { + // If no key or already a URL, return document as-is + return doc; + } + const url = await uploadService.getPresignedDownloadUrl(fileKey); return { ...doc, url }; } catch { return doc; diff --git a/src/services/users.service.ts b/src/services/users.service.ts index 4eb4976..7838853 100644 --- a/src/services/users.service.ts +++ b/src/services/users.service.ts @@ -11,7 +11,8 @@ export interface AgentType { } export interface VerificationDocument { - key: string; + id?: string; // S3 key is stored in id field from upload service + key?: string; // Alternative S3 key field name: string; size: number; type: string;