From 569be3e8e921b53765cab7de58f14f775ca4177b Mon Sep 17 00:00:00 2001 From: alma Date: Wed, 16 Apr 2025 10:48:58 +0200 Subject: [PATCH] mail page imap connection mime 5 bis rest 16 login page 32 --- app/mail/page.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/mail/page.tsx b/app/mail/page.tsx index b1f3d43..816bc94 100644 --- a/app/mail/page.tsx +++ b/app/mail/page.tsx @@ -449,10 +449,15 @@ export default function MailPage() { } const data = await response.json(); - console.log('Received emails:', data.length); + console.log('Received data:', data); - // Ensure all dates are Date objects - const processedEmails = data.map((email: Email) => ({ + if (!data.emails || !Array.isArray(data.emails)) { + console.error('Invalid response format:', data); + throw new Error('Invalid response format: emails array not found'); + } + + // Process the emails array from data.emails + const processedEmails = data.emails.map((email: Email) => ({ ...email, date: new Date(email.date), read: email.read || false, @@ -461,7 +466,7 @@ export default function MailPage() { })); setEmails(processedEmails); - console.log('Emails loaded successfully'); + console.log('Emails loaded successfully:', processedEmails.length); } catch (err) { console.error('Error loading emails:', err); setError(err instanceof Error ? err.message : 'Failed to load emails');