From f55bba3c1b8595d1ce1c8a9557c16dbedb8a9b65 Mon Sep 17 00:00:00 2001 From: Alma Date: Sun, 13 Apr 2025 21:35:59 +0200 Subject: [PATCH] widget email 15 --- app/api/emails/route.ts | 10 +++++++--- components/email.tsx | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/api/emails/route.ts b/app/api/emails/route.ts index e2da7e6c..633a0887 100644 --- a/app/api/emails/route.ts +++ b/app/api/emails/route.ts @@ -19,14 +19,18 @@ export async function GET(req: NextRequest) { ); } - // Return the Nextcloud Mail iframe URL + // Return the Nextcloud Mail iframe URL with an empty emails array return NextResponse.json({ - url: `${nextcloudUrl}/apps/mail/box/unified` + emails: [], // Initialize with empty array + mailUrl: `${nextcloudUrl}/apps/mail/box/unified` }); } catch (error) { console.error('Error getting Mail URL:', error); return NextResponse.json( - { error: "L'application Mail n'est pas disponible sur Nextcloud. Veuillez contacter votre administrateur." }, + { + error: "L'application Mail n'est pas disponible sur Nextcloud. Veuillez contacter votre administrateur.", + emails: [] // Initialize with empty array even in error case + }, { status: 404 } ); } diff --git a/components/email.tsx b/components/email.tsx index 4e87432b..1b1521e8 100644 --- a/components/email.tsx +++ b/components/email.tsx @@ -22,6 +22,7 @@ interface Email { interface EmailResponse { emails: Email[]; mailUrl: string; + error?: string; } export function Email() { @@ -56,7 +57,7 @@ export function Email() { throw new Error(data.error || 'Failed to fetch emails'); } - setEmails(data.emails); + setEmails(data.emails || []); setMailUrl(data.mailUrl); setError(null); } catch (err) {