'use client' import { useState } from 'react' import { createModule } from '@/lib/sdk/training/api' import { REGULATION_LABELS, FREQUENCY_LABELS } from '@/lib/sdk/training/types' export function ModuleCreateModal({ onClose, onSaved }: { onClose: () => void; onSaved: () => void }) { const [moduleCode, setModuleCode] = useState('') const [title, setTitle] = useState('') const [description, setDescription] = useState('') const [regulationArea, setRegulationArea] = useState('dsgvo') const [frequencyType, setFrequencyType] = useState('annual') const [durationMinutes, setDurationMinutes] = useState(45) const [passThreshold, setPassThreshold] = useState(70) const [saving, setSaving] = useState(false) const [error, setError] = useState(null) const handleSave = async () => { if (!moduleCode || !title) return setSaving(true) setError(null) try { await createModule({ module_code: moduleCode, title, description, regulation_area: regulationArea, frequency_type: frequencyType, duration_minutes: durationMinutes, pass_threshold: passThreshold }) onSaved() } catch (e) { setError(e instanceof Error ? e.message : 'Fehler beim Erstellen') } finally { setSaving(false) } } return (

Neues Trainingsmodul

setModuleCode(e.target.value.toUpperCase())} placeholder="DSGVO-BASICS" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500" />
setTitle(e.target.value)} className="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500" />