E-Mail-Ansicht: Postfach-Filter in Trash/Sent durchreichen
Bug: Im Vertrags-Tab (Gesendet/Gelöscht) und im Kunden-Haupt-
Postfach (Gelöscht) wurden Mails aus ALLEN Postfächern angezeigt,
unabhängig vom ausgewählten Postfach. Im Vertrag fehlte zusätzlich
der Vertrags-Filter im Papierkorb.
Backend:
- getEmailsForContract akzeptiert accountId → stressfreiEmailId
- getTrashEmails (controller + service) nimmt {accountId, contractId}
- getFolderCountsForContract bekommt optional stressfreiEmailId und
zusätzlich trash/trashUnread im Result
Frontend:
- API-Client (getForContract/getTrash/getContractFolderCounts) nimmt
Filter entgegen
- ContractEmailsSection reicht selectedAccountId in alle drei Queries
+ queryKey durch. Trash-Badge kommt jetzt aus contract-scoped
Counts statt account-globalem stressfreiEmailApi
- EmailClientTab reicht selectedAccountId in die Trash-Query durch
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -597,19 +597,24 @@ export const cachedEmailApi = {
|
||||
const res = await api.get<ApiResponse<CachedEmail[]>>(`/customers/${customerId}/emails`, { params: options });
|
||||
return res.data;
|
||||
},
|
||||
// E-Mails für Vertrag abrufen
|
||||
getForContract: async (contractId: number, options?: { folder?: 'INBOX' | 'SENT'; limit?: number; offset?: number }) => {
|
||||
// E-Mails für Vertrag abrufen (optional pro Postfach gefiltert)
|
||||
getForContract: async (
|
||||
contractId: number,
|
||||
options?: { folder?: 'INBOX' | 'SENT'; accountId?: number; limit?: number; offset?: number },
|
||||
) => {
|
||||
const res = await api.get<ApiResponse<CachedEmail[]>>(`/contracts/${contractId}/emails`, { params: options });
|
||||
return res.data;
|
||||
},
|
||||
// Ordner-Anzahlen für Vertrag abrufen (zugeordnete E-Mails)
|
||||
getContractFolderCounts: async (contractId: number) => {
|
||||
// Ordner-Anzahlen für Vertrag abrufen (zugeordnete E-Mails, optional pro Postfach)
|
||||
getContractFolderCounts: async (contractId: number, accountId?: number) => {
|
||||
const res = await api.get<ApiResponse<{
|
||||
inbox: number;
|
||||
inboxUnread: number;
|
||||
sent: number;
|
||||
sentUnread: number;
|
||||
}>>(`/contracts/${contractId}/emails/folder-counts`);
|
||||
trash: number;
|
||||
trashUnread: number;
|
||||
}>>(`/contracts/${contractId}/emails/folder-counts`, { params: accountId ? { accountId } : undefined });
|
||||
return res.data;
|
||||
},
|
||||
// Mailbox-Konten eines Kunden abrufen
|
||||
@@ -669,14 +674,14 @@ export const cachedEmailApi = {
|
||||
return res.data;
|
||||
},
|
||||
// ==================== PAPIERKORB ====================
|
||||
// Papierkorb-E-Mails für Kunden abrufen
|
||||
getTrash: async (customerId: number) => {
|
||||
const res = await api.get<ApiResponse<CachedEmail[]>>(`/customers/${customerId}/emails/trash`);
|
||||
// Papierkorb-E-Mails für Kunden abrufen (optional pro Postfach/Vertrag gefiltert)
|
||||
getTrash: async (customerId: number, options?: { accountId?: number; contractId?: number }) => {
|
||||
const res = await api.get<ApiResponse<CachedEmail[]>>(`/customers/${customerId}/emails/trash`, { params: options });
|
||||
return res.data;
|
||||
},
|
||||
// Papierkorb-Anzahl für Kunden
|
||||
getTrashCount: async (customerId: number) => {
|
||||
const res = await api.get<ApiResponse<{ count: number }>>(`/customers/${customerId}/emails/trash/count`);
|
||||
// Papierkorb-Anzahl für Kunden (gleiche Filter wie getTrash)
|
||||
getTrashCount: async (customerId: number, options?: { accountId?: number; contractId?: number }) => {
|
||||
const res = await api.get<ApiResponse<{ count: number }>>(`/customers/${customerId}/emails/trash/count`, { params: options });
|
||||
return res.data;
|
||||
},
|
||||
// E-Mail aus Papierkorb wiederherstellen
|
||||
|
||||
Reference in New Issue
Block a user