/** * Dashboard Page * * System-Übersicht für den User. * Zeigt alle verfügbaren Feature-Instanzen pro Mandant als Karten an. * Daten kommen vom Backend via GET /api/navigation. */ import React from 'react'; import { Link } from 'react-router-dom'; import useNavigation from '../hooks/useNavigation'; import type { NavigationMandate, MandateFeature, FeatureInstance as NavFeatureInstance } from '../hooks/useNavigation'; import { getPageIcon } from '../config/pageRegistry'; import { FaArrowRight, FaBuilding } from 'react-icons/fa'; import OnboardingAssistant from '../components/OnboardingAssistant'; import styles from './Dashboard.module.css'; import { useLanguage } from '../providers/language/LanguageContext'; // ============================================================================= // INSTANCE CARD // ============================================================================= interface InstanceCardProps { instance: NavFeatureInstance; feature: MandateFeature; } const InstanceCard: React.FC = ({ instance, feature }) => { // Ersten verfügbaren View-Pfad vom Backend nehmen const targetPath = instance.views.length > 0 ? instance.views[0].uiPath : undefined; if (!targetPath) return null; return (
{getPageIcon(feature.uiComponent)}
{feature.uiLabel}

{instance.uiLabel}

); }; // ============================================================================= // DASHBOARD PAGE // ============================================================================= export const DashboardPage: React.FC = () => { const { t } = useLanguage(); const { dynamicBlock, loading } = useNavigation(); // Alle Mandate und deren Features/Instanzen aus der Navigation const mandates: NavigationMandate[] = dynamicBlock?.mandates || []; // Gesamtzahl Instanzen und Mandate berechnen let totalInstances = 0; const totalMandates = mandates.length; mandates.forEach(m => m.features.forEach(f => { totalInstances += f.instances.length; })); if (loading) { return (

{t('Übersicht')}

{t('Lade')}

); } return (

{t('Übersicht')}

{totalInstances > 0 && (

{t('Du hast Zugriff auf {instanceCount} {instanceWord} in {mandateCount} {mandateWord}.', { instanceCount: totalInstances, instanceWord: totalInstances === 1 ? t('Feature-Instanz') : t('Feature-Instanzen'), mandateCount: totalMandates, mandateWord: totalMandates === 1 ? t('Mandant') : t('Mandanten'), })}

)}
{mandates .filter(mandate => mandate.features.some(f => f.instances.length > 0)) .map(mandate => { // Alle Instanzen dieses Mandats sammeln (flach, ohne Feature-Gruppierung) const mandateInstances: { instance: NavFeatureInstance; feature: MandateFeature }[] = []; for (const feature of mandate.features) { for (const instance of feature.instances) { mandateInstances.push({ instance, feature }); } } return (

{mandate.uiLabel}

{mandateInstances.map(({ instance, feature }) => ( ))}
); })}
); }; export default DashboardPage;