'use client' import { useState } from 'react' import type { EmailAccount } from '../types' import { API_BASE } from '../constants' import AddAccountModal from './AddAccountModal' export default function AccountsTab({ accounts, loading, onRefresh }: { accounts: EmailAccount[] loading: boolean onRefresh: () => void }) { const [showAddModal, setShowAddModal] = useState(false) const testConnection = async (accountId: string) => { try { const res = await fetch(`${API_BASE}/api/v1/mail/accounts/${accountId}/test`, { method: 'POST', }) if (res.ok) { alert('Verbindung erfolgreich!') } else { alert('Verbindungsfehler') } } catch (err) { alert('Verbindungsfehler') } } const statusColors = { active: 'bg-green-100 text-green-800', inactive: 'bg-gray-100 text-gray-800', error: 'bg-red-100 text-red-800', syncing: 'bg-yellow-100 text-yellow-800', } const statusLabels = { active: 'Aktiv', inactive: 'Inaktiv', error: 'Fehler', syncing: 'Synchronisiert...', } return (
{/* Header */}

E-Mail-Konten

Verwalten Sie die verbundenen E-Mail-Konten

{/* Loading State */} {loading && (
)} {/* Accounts Grid */} {!loading && (
{accounts.length === 0 ? (

Keine E-Mail-Konten

Fügen Sie Ihr erstes E-Mail-Konto hinzu.

) : ( accounts.map((account) => (

{account.displayName || account.email}

{account.email}

{statusLabels[account.status]}

E-Mails

{account.emailCount}

Ungelesen

{account.unreadCount}

IMAP

{account.imapHost}:{account.imapPort}

Letzte Sync

{account.lastSync ? new Date(account.lastSync).toLocaleString('de-DE') : 'Nie'}

)) )}
)} {/* Add Account Modal */} {showAddModal && ( setShowAddModal(false)} onSuccess={() => { setShowAddModal(false); onRefresh(); }} /> )}
) }