From 6fb50f1209f8dba939ad84dfd440e2df5c78fb25 Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 25 Apr 2025 19:06:29 +0200 Subject: [PATCH] panel 2 courier api restore --- app/courrier/page.tsx | 56 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index b6155414..afa85b7a 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -1,6 +1,7 @@ 'use client'; import { useEffect, useState, useMemo, useCallback, useRef } from 'react'; +import React from 'react'; import { useRouter } from 'next/navigation'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; @@ -569,6 +570,13 @@ export default function CourrierPage() { // Set available folders if present if (data.folders) { setAvailableFolders(data.folders); + + // Update the mail account with folders + setAccounts(prev => prev.map(account => + account.id === 1 + ? { ...account, folders: data.folders } + : account + )); } // Process emails and sort by date @@ -1176,7 +1184,7 @@ export default function CourrierPage() { id: Number(email.id), accountId: 1, from: email.from || '', - fromName: email.from?.split('@')[0] || '', + fromName: email.fromName || email.from?.split('@')[0] || '', to: email.to || '', subject: email.subject || '(No subject)', body: email.body || '', @@ -1193,6 +1201,18 @@ export default function CourrierPage() { setEmails(processedEmails); setHasMore(processedEmails.length === emailsPerPage); + // If folders are returned, update them + if (data.folders && data.folders.length > 0) { + setAvailableFolders(data.folders); + + // Update the mail account with folders + setAccounts(prev => prev.map(account => + account.id === 1 + ? { ...account, folders: data.folders } + : account + )); + } + // Only update unread count if we're in the Inbox folder if (newMailbox === 'INBOX') { const unreadInboxEmails = processedEmails.filter( @@ -1610,6 +1630,40 @@ export default function CourrierPage() { {account.email} + + {/* Show folders for email accounts (not for "All" account) */} + {account.id !== 0 && account.folders && account.folders.length > 0 && ( +
+
+ Folders +
+ {account.folders.map((folder) => ( + + ))} +
+ )} ))}