panel 2 courier api restore

This commit is contained in:
alma 2025-04-25 19:28:40 +02:00
parent 981567f813
commit ca93e4bc26

View File

@ -425,8 +425,8 @@ export default function CourrierPage() {
const { data: session } = useSession();
const [loading, setLoading] = useState(true);
const [accounts, setAccounts] = useState<Account[]>([
{ id: 0, name: 'All', email: '', color: 'bg-gray-500' },
{ id: 1, name: 'Mail', email: 'alma@governance-labs.org', color: 'bg-blue-500' }
{ id: 0, name: 'All', email: '', color: 'bg-gray-400' },
{ id: 1, name: '', email: '', color: 'bg-blue-500' }
]);
const [selectedAccount, setSelectedAccount] = useState<Account | null>(null);
const [currentView, setCurrentView] = useState<MailFolder>('INBOX');
@ -648,6 +648,17 @@ export default function CourrierPage() {
loadInitialData();
}, [router, currentView, page, emailsPerPage]);
// At the initialization, update the account with the email from session
useEffect(() => {
if (session?.user?.email) {
setAccounts(prev => prev.map(account =>
account.id === 1
? { ...account, name: session.user.email, email: session.user.email }
: account
));
}
}, [session?.user?.email]);
// Get account color
const getAccountColor = (accountId: number) => {
const account = accounts.find(acc => acc.id === accountId);
@ -1751,18 +1762,17 @@ export default function CourrierPage() {
<div className="flex flex-col items-start">
<div className="flex items-center gap-2">
<div className={`w-2.5 h-2.5 rounded-full ${account.color}`}></div>
<span className="font-medium">{account.name}</span>
<span className="font-medium text-gray-700">{account.name || 'Mail Account'}</span>
</div>
<span className="text-xs text-gray-500 ml-4">{account.email}</span>
{account.id !== 0 && account.email && (
<span className="text-xs text-gray-500 ml-4">{account.email}</span>
)}
</div>
</Button>
{/* Show folders for email accounts (not for "All" account) */}
{/* Show folders for email accounts (not for "All" account) without the "Folders" header */}
{account.id !== 0 && (
<div className="pl-4 mt-1 mb-2 space-y-0.5 border-l border-gray-200">
<div className="px-2 py-1 text-xs text-gray-500 font-medium flex justify-between items-center">
<span>Folders</span>
</div>
{account.folders && account.folders.length > 0 ? (
account.folders.map((folder) => (
<Button