mail page imap connection mime 5 bis rest 6
This commit is contained in:
parent
22dc2a74d8
commit
e013913f4d
@ -388,7 +388,7 @@ function decodeMimeContent(content: string): string {
|
||||
export default function MailPage() {
|
||||
// Single IMAP account for now
|
||||
const [accounts, setAccounts] = useState<Account[]>([
|
||||
{ id: 1, name: 'Mail', email: 'contact@governance-labs.org', color: 'bg-blue-500' },
|
||||
{ id: 1, name: 'Mail', email: 'alma@governance-labs.org', color: 'bg-blue-500' },
|
||||
{ id: 2, name: 'Work', email: 'work@governance-labs.org', color: 'bg-green-500' }
|
||||
]);
|
||||
|
||||
@ -427,7 +427,7 @@ export default function MailPage() {
|
||||
throw new Error('Failed to fetch emails');
|
||||
}
|
||||
const data = await response.json();
|
||||
console.log('Raw API Response:', data); // Debug raw response
|
||||
console.log('API Response:', data); // Debug log
|
||||
|
||||
// Handle different possible response formats
|
||||
let emailData = [];
|
||||
@ -445,18 +445,25 @@ export default function MailPage() {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Processed email data:', emailData); // Debug processed data
|
||||
console.log('Processed email data:', emailData); // Debug log
|
||||
|
||||
// Ensure all dates are Date objects
|
||||
const processedEmails = emailData.map((email: Email) => ({
|
||||
...email,
|
||||
// Ensure all dates are Date objects and add required properties
|
||||
const processedEmails = emailData.map((email: any) => ({
|
||||
id: email.id || email.uid || email.messageId || Math.random().toString(),
|
||||
accountId: email.accountId || '1',
|
||||
from: email.from || '',
|
||||
fromName: email.fromName || email.from?.split('@')[0] || '',
|
||||
to: email.to || '',
|
||||
subject: email.subject || '(No Subject)',
|
||||
body: email.body || email.text || email.html || '',
|
||||
preview: email.preview || email.body?.substring(0, 100) || '',
|
||||
category: email.category || 'inbox',
|
||||
date: email.date ? new Date(email.date) : new Date(),
|
||||
read: email.read || false,
|
||||
starred: email.starred || false,
|
||||
category: email.category || 'inbox'
|
||||
starred: email.starred || false
|
||||
}));
|
||||
|
||||
console.log('Final processed emails:', processedEmails); // Debug final data
|
||||
console.log('Final processed emails:', processedEmails); // Debug log
|
||||
setEmails(processedEmails);
|
||||
} catch (err) {
|
||||
console.error('Error fetching emails:', err);
|
||||
@ -482,7 +489,7 @@ export default function MailPage() {
|
||||
];
|
||||
|
||||
// Filter emails based on current view
|
||||
const filteredEmails = Array.isArray(emails) ? emails.filter(email => {
|
||||
const filteredEmails = emails.filter(email => {
|
||||
if (selectedAccount === 0) return true;
|
||||
return email.accountId === selectedAccount.toString();
|
||||
}).filter(email => {
|
||||
@ -498,7 +505,7 @@ export default function MailPage() {
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}) : [];
|
||||
});
|
||||
|
||||
// Format date for display
|
||||
const formatDate = (dateString: string) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user