fix(buchhaltung): clean up tab labels, remove badge indicator, add session notification for pending transactions

This commit is contained in:
Matthias Hochmeister
2026-04-14 13:35:40 +02:00
parent 3a8f166121
commit f403c73334
3 changed files with 40 additions and 10 deletions

View File

@@ -0,0 +1,36 @@
import { useEffect } from 'react';
import { buchhaltungApi } from '../../services/buchhaltung';
import { useNotification } from '../../contexts/NotificationContext';
import { usePermissionContext } from '../../contexts/PermissionContext';
const SESSION_KEY = 'buchhaltung-pending-notified';
/**
* Invisible component — checks for pending (entwurf) transactions once per session
* and shows a notification toast if any exist.
*/
function BuchhaltungPendingNotifier() {
const { showNotificationToast } = useNotification();
const { hasPermission } = usePermissionContext();
useEffect(() => {
if (!hasPermission('buchhaltung:view')) return;
if (sessionStorage.getItem(SESSION_KEY)) return;
sessionStorage.setItem(SESSION_KEY, '1');
buchhaltungApi.getPendingCount().then(count => {
if (count > 0) {
showNotificationToast(
`${count} offene Buchung${count > 1 ? 'en' : ''} ausstehend`,
'warning',
);
}
}).catch(() => { /* ignore */ });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
}
export default BuchhaltungPendingNotifier;