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 response = await fetch('/api/mail');
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
|
console.log('Raw API response:', data); // Debug log
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
if (response.status === 401) {
|
if (response.status === 401) {
|
||||||
signIn();
|
signIn();
|
||||||
@ -49,8 +51,14 @@ export function Email() {
|
|||||||
throw new Error(data.error || 'Failed to fetch emails');
|
throw new Error(data.error || 'Failed to fetch emails');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transform the raw emails into the expected format
|
// Make sure we're accessing the emails array from the response
|
||||||
const transformedEmails = (data || []).map((email: any) => ({
|
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),
|
id: String(email.id),
|
||||||
subject: email.subject || '(No subject)',
|
subject: email.subject || '(No subject)',
|
||||||
sender: {
|
sender: {
|
||||||
@ -61,6 +69,8 @@ export function Email() {
|
|||||||
isUnread: !email.read
|
isUnread: !email.read
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
console.log('Transformed emails:', transformedEmails); // Debug log
|
||||||
|
|
||||||
setEmails(transformedEmails);
|
setEmails(transformedEmails);
|
||||||
setMailUrl(data.mailUrl);
|
setMailUrl(data.mailUrl);
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user