'use client' import React, { useState, useEffect, useCallback } from 'react' // ============================================================================= // TYPES // ============================================================================= interface WorkshopSession { id: string title: string description: string session_type: 'ucca' | 'dsfa' | 'custom' status: 'DRAFT' | 'SCHEDULED' | 'ACTIVE' | 'PAUSED' | 'COMPLETED' | 'CANCELLED' current_step: number total_steps: number join_code: string require_auth: boolean allow_anonymous: boolean scheduled_start: string | null scheduled_end: string | null actual_start: string | null actual_end: string | null assessment_id: string | null roadmap_id: string | null portfolio_id: string | null created_at: string updated_at: string } interface Participant { id: string session_id: string user_id: string | null name: string email: string role: 'FACILITATOR' | 'EXPERT' | 'STAKEHOLDER' | 'OBSERVER' department: string is_active: boolean last_active_at: string | null joined_at: string can_edit: boolean can_comment: boolean can_approve: boolean } interface WorkshopResponse { id: string session_id: string participant_id: string step_number: number field_id: string value: unknown value_type: string response_status: 'PENDING' | 'DRAFT' | 'SUBMITTED' | 'REVIEWED' created_at: string } interface WorkshopComment { id: string session_id: string participant_id: string step_number: number | null field_id: string | null text: string is_resolved: boolean created_at: string } interface SessionStats { total_participants: number active_participants: number total_responses: number completed_steps: number total_steps: number progress: number } // ============================================================================= // API // ============================================================================= const API_BASE = '/api/sdk/v1/workshops' async function api(path: string, options?: RequestInit): Promise { const res = await fetch(`${API_BASE}${path}`, { headers: { 'Content-Type': 'application/json' }, ...options, }) if (!res.ok) { const err = await res.json().catch(() => ({ error: res.statusText })) throw new Error(err.error || err.message || `HTTP ${res.status}`) } return res.json() } // ============================================================================= // COMPONENTS // ============================================================================= const statusColors: Record = { DRAFT: 'bg-gray-100 text-gray-700', SCHEDULED: 'bg-blue-100 text-blue-700', ACTIVE: 'bg-green-100 text-green-700', PAUSED: 'bg-yellow-100 text-yellow-700', COMPLETED: 'bg-purple-100 text-purple-700', CANCELLED: 'bg-red-100 text-red-700', } const statusLabels: Record = { DRAFT: 'Entwurf', SCHEDULED: 'Geplant', ACTIVE: 'Aktiv', PAUSED: 'Pausiert', COMPLETED: 'Abgeschlossen', CANCELLED: 'Abgebrochen', } const typeLabels: Record = { ucca: 'UCCA Assessment', dsfa: 'DSFA Workshop', custom: 'Benutzerdefiniert', } function SessionCard({ session, onSelect, onDelete }: { session: WorkshopSession onSelect: (s: WorkshopSession) => void onDelete: (id: string) => void }) { const progress = session.total_steps > 0 ? Math.round((session.current_step / session.total_steps) * 100) : 0 return (
onSelect(session)}>

{session.title}

{typeLabels[session.session_type] || session.session_type}
{statusLabels[session.status] || session.status}
{session.description && (

{session.description}

)}
Code: {session.join_code} Schritt {session.current_step}/{session.total_steps}
{new Date(session.created_at).toLocaleDateString('de-DE')}
) } function CreateSessionModal({ onClose, onCreated }: { onClose: () => void onCreated: () => void }) { const [title, setTitle] = useState('') const [description, setDescription] = useState('') const [sessionType, setSessionType] = useState<'ucca' | 'dsfa' | 'custom'>('custom') const [totalSteps, setTotalSteps] = useState(5) const [saving, setSaving] = useState(false) const handleCreate = async () => { if (!title.trim()) return setSaving(true) try { await api('', { method: 'POST', body: JSON.stringify({ title: title.trim(), description: description.trim(), session_type: sessionType, total_steps: totalSteps, }), }) onCreated() } catch (err) { console.error('Create session error:', err) } finally { setSaving(false) } } return (
e.stopPropagation()}>

Neuer Workshop

setTitle(e.target.value)} className="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" placeholder="z.B. DSFA Workshop Q1" />