/** * CommCoach Dashboard View * * Shows KPIs, streak, active contexts, and quick-start coaching entry. */ import React from 'react'; import { useNavigate } from 'react-router-dom'; import { useCommcoachDashboard } from '../../../hooks/useCommcoachDashboard'; import { useCurrentInstance } from '../../../hooks/useCurrentInstance'; import styles from './CommcoachDashboardView.module.css'; import { useLanguage } from '../../../providers/language/LanguageContext'; export const CommcoachDashboardView: React.FC = () => { const { t } = useLanguage(); const navigate = useNavigate(); const { mandateId, instanceId } = useCurrentInstance(); const { dashboard, loading, error } = useCommcoachDashboard(); const handleContextClick = (contextId: string) => { if (mandateId && instanceId) { navigate(`/mandates/${mandateId}/commcoach/${instanceId}/coaching?context=${contextId}`); } }; if (loading && !dashboard) { return
{t('Dashboard wird geladen…')}
; } if (error) { return
{error}
; } if (!dashboard) { return
{t('Keine Daten verfügbar')}
; } return (
{/* KPI Cards */}
{dashboard.streakDays}
{t('Tage in Folge')}
Rekord: {dashboard.longestStreak}
{dashboard.totalSessions}
Sessions
{dashboard.totalMinutes} Min. gesamt
{dashboard.averageScore != null ? Math.round(dashboard.averageScore) : '--'}
Kompetenz-Score
Durchschnitt
{dashboard.goalProgress != null ? `${dashboard.goalProgress}%` : '--'}
Zielfortschritt
{dashboard.openTasks} offene Aufgaben
{/* Active Contexts */}

{t('Aktive Coaching-Themen')}

{dashboard.contexts.length === 0 ? (

{t('Noch keine Coaching-Themen angelegt.')}

{t('Wechseln Sie zum Tab Coaching, um ein Thema anzulegen.')}

) : (
{dashboard.contexts.map(ctx => (
handleContextClick(ctx.id)} role="button" tabIndex={0} onKeyDown={e => e.key === 'Enter' && handleContextClick(ctx.id)} >
{ctx.title}
{_categoryLabel(ctx.category)} {ctx.sessionCount} Sessions {ctx.goalProgress != null && Ziele: {ctx.goalProgress}%}
{ctx.lastSessionAt && (
Letzte Session: {_formatDate(ctx.lastSessionAt)}
)}
))}
)}
{/* Level + Badges */} {(dashboard.level || (dashboard.badges && dashboard.badges.length > 0)) && (

{dashboard.level ? `Level ${dashboard.level.number}: ${dashboard.level.label}` : 'Auszeichnungen'}

{dashboard.badges && dashboard.badges.length > 0 && (
{dashboard.badges.map(b => (
{_badgeIcon(b.icon)}
{b.label || b.badgeKey}
))}
)}
)} {/* Quick Start */}

{t('Tipp des Tages')}

Konsistenz schlägt Intensität. Auch 10 Minuten tägliches Coaching-Gespräch bringt messbare Fortschritte in deiner Kommunikationskompetenz.

); }; function _categoryLabel(category: string): string { const labels: Record = { leadership: 'Führung', conflict: 'Konflikt', negotiation: 'Verhandlung', presentation: 'Präsentation', feedback: 'Feedback', delegation: 'Delegation', changeManagement: 'Change Mgmt', custom: 'Individuell', }; return labels[category] || category; } function _badgeIcon(icon?: string): string { const icons: Record = { star: '\u2605', fire: '\u{1F525}', trophy: '\u{1F3C6}', medal: '\u{1F3C5}', layers: '\u{1F4DA}', theater: '\u{1F3AD}', compass: '\u{1F9ED}', 'check-circle': '\u2714', }; return icons[icon || 'star'] || '\u2605'; } function _formatDate(isoStr: string): string { try { const d = new Date(isoStr); return d.toLocaleDateString('de-CH', { day: '2-digit', month: '2-digit', year: 'numeric' }); } catch { return isoStr; } } export default CommcoachDashboardView;