/** * CommCoach Assistant View * * Wizard flow: Module type → Topic → Persona → KPIs → "Start first session" */ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useCurrentInstance } from '../../../hooks/useCurrentInstance'; import * as commcoachApi from '../../../api/commcoachApi'; import { useLanguage } from '../../../providers/language/LanguageContext'; import styles from './Commcoach.module.css'; type WizardStep = 'type' | 'topic' | 'persona' | 'kpis' | 'confirm'; const STEPS: WizardStep[] = ['type', 'topic', 'persona', 'kpis', 'confirm']; const MODULE_TYPES = [ { value: 'coaching', label: 'Coaching', icon: '🎯' }, { value: 'training', label: 'Training', icon: '📚' }, { value: 'exam', label: 'Prüfung', icon: '✍️' }, { value: 'elearning', label: 'E-Learning', icon: '💻' }, ]; export const CommcoachAssistantView: React.FC = () => { const { t } = useLanguage(); const { instance, mandateId } = useCurrentInstance(); const instanceId = instance?.id || ''; const navigate = useNavigate(); const [step, setStep] = useState('type'); const [moduleType, setModuleType] = useState('coaching'); const [title, setTitle] = useState(''); const [goals, setGoals] = useState(''); const [personaId, setPersonaId] = useState(null); const [_personas, _setPersonas] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const stepIdx = STEPS.indexOf(step); const _handleNext = () => { const nextIdx = stepIdx + 1; if (nextIdx < STEPS.length) setStep(STEPS[nextIdx]); }; const _handleBack = () => { const prevIdx = stepIdx - 1; if (prevIdx >= 0) setStep(STEPS[prevIdx]); }; const _handleCreate = async () => { if (!title.trim()) { setError(t('Bitte einen Titel eingeben')); return; } setLoading(true); setError(null); try { const apiRequest = commcoachApi.getApiRequest(); const module = await commcoachApi.createModuleApi(apiRequest, instanceId, { title: title.trim(), moduleType, goals: goals.trim() || undefined, personaId: personaId || undefined, }); navigate(`/mandates/${mandateId}/commcoach/${instanceId}/session?moduleId=${module.id}`); } catch (err: any) { setError(err?.message || t('Fehler beim Erstellen')); } finally { setLoading(false); } }; return (

{t('Neues Modul erstellen')}

{STEPS.map((s, i) => (
))}
{stepIdx > 0 && ( )} {step !== 'confirm' ? ( ) : ( )}
{error &&
{error}
}
{step === 'type' && (

{t('Modul-Typ wählen')}

{MODULE_TYPES.map(mt => ( ))}
)} {step === 'topic' && (

{t('Thema & Titel')}

setTitle(e.target.value)} autoFocus />