mail page imap connection mime 5 bis rest 16 login page 27
This commit is contained in:
parent
2253478e76
commit
a7d06570d6
@ -41,6 +41,8 @@ export function Email() {
|
||||
const response = await fetch('/api/mail');
|
||||
const data = await response.json();
|
||||
|
||||
console.log('Raw API response:', data); // Debug log
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 401) {
|
||||
signIn();
|
||||
@ -49,8 +51,14 @@ export function Email() {
|
||||
throw new Error(data.error || 'Failed to fetch emails');
|
||||
}
|
||||
|
||||
// Transform the raw emails into the expected format
|
||||
const transformedEmails = (data || []).map((email: any) => ({
|
||||
// Make sure we're accessing the emails array from the response
|
||||
if (!Array.isArray(data.emails)) {
|
||||
console.error('Expected emails array in response, got:', data);
|
||||
throw new Error('Invalid response format: emails array not found');
|
||||
}
|
||||
|
||||
// Transform the emails array into the expected format
|
||||
const transformedEmails = data.emails.map((email: any) => ({
|
||||
id: String(email.id),
|
||||
subject: email.subject || '(No subject)',
|
||||
sender: {
|
||||
@ -61,6 +69,8 @@ export function Email() {
|
||||
isUnread: !email.read
|
||||
}));
|
||||
|
||||
console.log('Transformed emails:', transformedEmails); // Debug log
|
||||
|
||||
setEmails(transformedEmails);
|
||||
setMailUrl(data.mailUrl);
|
||||
setError(null);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user