/** * Dashboard Page * * System-Übersicht für den User. * Zeigt alle verfügbaren Feature-Instanzen 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 } from 'react-icons/fa'; import styles from './Dashboard.module.css'; // ============================================================================= // INSTANCE CARD // ============================================================================= interface InstanceCardProps { instance: NavFeatureInstance; feature: MandateFeature; mandateLabel: string; } const InstanceCard: React.FC = ({ instance, feature, mandateLabel }) => { // 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}

{mandateLabel}

); }; // ============================================================================= // EMPTY STATE // ============================================================================= const EmptyState: React.FC = () => (
📋

Willkommen bei PowerOn

Du hast aktuell Zugriff auf keine Feature-Instanzen.

Kontaktiere einen Administrator, um Zugriff zu erhalten.

); // ============================================================================= // DASHBOARD PAGE // ============================================================================= export const DashboardPage: React.FC = () => { 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 (

Übersicht

Lade...

); } if (totalInstances === 0) { return ; } // Gruppiere Instanzen nach Feature (über alle Mandate) const featureGroups: { feature: MandateFeature; instances: { instance: NavFeatureInstance; mandateLabel: string }[] }[] = []; const featureMap = new Map(); for (const mandate of mandates) { for (const feature of mandate.features) { const key = feature.uiComponent; let group = featureMap.get(key); if (!group) { group = { feature, instances: [] }; featureMap.set(key, group); featureGroups.push(group); } for (const instance of feature.instances) { group.instances.push({ instance, mandateLabel: mandate.uiLabel }); } } } return (

Übersicht

Du hast Zugriff auf {totalInstances} Feature-Instanz{totalInstances !== 1 ? 'en' : ''} in {totalMandates} Mandant{totalMandates !== 1 ? 'en' : ''}.

{featureGroups.map(({ feature, instances }) => (

{getPageIcon(feature.uiComponent)} {feature.uiLabel}

{instances.map(({ instance, mandateLabel }) => ( ))}
))}
); }; export default DashboardPage;