From 90d9aaafd9dd9fcef79d81b88ac1fa9448492389 Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 25 Apr 2025 11:22:17 +0200 Subject: [PATCH] panel 2 courier --- components/email.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/email.tsx b/components/email.tsx index d12a9493..657ebbd3 100644 --- a/components/email.tsx +++ b/components/email.tsx @@ -47,7 +47,7 @@ export function Email() { if (!isRefresh) setLoading(true); try { - const response = await fetch('/api/mail'); + const response = await fetch('/api/courrier?folder=INBOX&page=1&limit=5'); if (!response.ok) { const errorData = await response.json(); @@ -60,8 +60,8 @@ export function Email() { throw new Error(data.error); } - const validatedEmails = data.emails.map((email: any) => ({ - id: email.id || Date.now().toString(), + const validatedEmails = (data.emails || []).map((email: any) => ({ + id: email.id?.toString() || Date.now().toString(), subject: email.subject || '(No subject)', from: email.from || '', fromName: email.fromName || email.from?.split('@')[0] || 'Unknown', @@ -72,7 +72,7 @@ export function Email() { })); setEmails(validatedEmails); - setMailUrl(data.mailUrl || 'https://espace.slm-lab.net/apps/courrier/'); + setMailUrl('/courrier'); setError(null); } catch (err) { setError(err instanceof Error ? err.message : 'Error fetching emails'); @@ -169,7 +169,7 @@ export function Email() {
router.push('/mail')} + onClick={() => router.push('/courrier')} >