'use client' import { useState } from 'react' import { createModule } from '@/lib/sdk/training/api' import { REGULATION_LABELS, FREQUENCY_LABELS } from '@/lib/sdk/training/types' export default function ModuleCreateModal({ onClose, onSaved, }: { onClose: () => void onSaved: () => void }) { const [saving, setSaving] = useState(false) const [error, setError] = useState(null) async function handleSubmit(e: React.FormEvent) { e.preventDefault() setSaving(true) setError(null) const fd = new FormData(e.currentTarget) try { await createModule({ module_code: fd.get('module_code') as string, title: fd.get('title') as string, description: (fd.get('description') as string) || undefined, regulation_area: fd.get('regulation_area') as string, frequency_type: fd.get('frequency_type') as string, duration_minutes: parseInt(fd.get('duration_minutes') as string) || 30, pass_threshold: parseInt(fd.get('pass_threshold') as string) || 80, }) onSaved() } catch (err) { setError(err instanceof Error ? err.message : 'Fehler beim Erstellen') } finally { setSaving(false) } } return (

Neues Schulungsmodul

{error && (
{error}
)}