From 6c5baa6f403a823ee665ef42259417f1e8862371 Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 25 Apr 2025 19:34:47 +0200 Subject: [PATCH] panel 2 courier api restore --- app/courrier/page.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index a9b226ef..445ded7d 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -1681,37 +1681,40 @@ export default function CourrierPage() { }; }, [accounts, loading]); - // Add a function to fetch the IMAP credentials directly - const fetchMailCredentials = async () => { + // Add a new function to fetch the IMAP credentials email + const fetchImapCredentials = async () => { try { - const response = await fetch('/api/courrier'); + const response = await fetch('/api/courrier/credentials'); if (!response.ok) { + console.error('Failed to fetch IMAP credentials', response.status); return; } const data = await response.json(); - // If we have email credentials, update the account - if (data && data.email) { - console.log('Got IMAP email:', data.email); + // If we have credentials with an email, update the account + if (data && data.credentials && data.credentials.email) { + console.log('Got IMAP credentials email:', data.credentials.email); setAccounts(prev => prev.map(account => account.id === 1 ? { ...account, - name: data.email, - email: data.email + name: data.credentials.email, + email: data.credentials.email } : account )); + } else { + console.warn('No IMAP email found in credentials'); } } catch (error) { - console.error('Error fetching mail credentials:', error); + console.error('Error fetching IMAP credentials:', error); } }; // Call it once on component mount useEffect(() => { - fetchMailCredentials(); + fetchImapCredentials(); }, []); if (error) {