diff --git a/src/app/dashboard/cms/page.tsx b/src/app/dashboard/cms/page.tsx index d559382..cc1afc4 100644 --- a/src/app/dashboard/cms/page.tsx +++ b/src/app/dashboard/cms/page.tsx @@ -237,21 +237,22 @@ export default function CmsPage() { agentSearchTimeout.current = setTimeout(async () => { try { const res = await usersService.getUsers({ role: 'AGENT', search: query, limit: 10, verificationStatus: 'APPROVED' }); - // Resolve avatar presigned URLs for display - const usersWithAvatars = await Promise.all( + // Resolve avatar presigned URLs for dropdown display only + // Store resolved URLs separately so original S3 keys are preserved for CMS storage + const usersWithDisplayAvatars = await Promise.all( res.users.map(async (user) => { if (user.profile?.avatar && !user.profile.avatar.startsWith('http')) { try { - const avatarUrl = await uploadService.getPresignedDownloadUrl(user.profile.avatar); - return { ...user, profile: { ...user.profile, avatar: avatarUrl } }; + const displayUrl = await uploadService.getPresignedDownloadUrl(user.profile.avatar); + return { ...user, _displayAvatar: displayUrl }; } catch { - return user; + return { ...user, _displayAvatar: undefined }; } } - return user; + return { ...user, _displayAvatar: user.profile?.avatar || undefined }; }) ); - setAgentSearchResults(usersWithAvatars); + setAgentSearchResults(usersWithDisplayAvatars as any); } catch { setAgentSearchResults([]); } finally { @@ -612,8 +613,8 @@ export default function CmsPage() { {user.profile?.firstName?.[0] || ''}{user.profile?.lastName?.[0] || ''} - {user.profile?.avatar && ( - { (e.target as HTMLImageElement).style.display = 'none'; }} /> + {(user as any)._displayAvatar && ( + { (e.target as HTMLImageElement).style.display = 'none'; }} /> )}