'use client' import { useState } from 'react' import { useTheme } from '@/lib/ThemeContext' import { calendarApi } from '@/lib/schulkalender/api' import type { CreateSchoolEvent, SchoolEventType } from '@/app/schulkalender/types' import { EVENT_TYPE_LABEL } from '@/app/schulkalender/types' interface EventModalProps { defaultDate: string // YYYY-MM-DD onClose: () => void onCreated: () => void } const initial = (date: string): CreateSchoolEvent => ({ title: '', event_type: 'fortbildung', is_school_free: false, start_date: date, end_date: date, visible_to_parents: true, notify_parents: false, notify_students: false, notification_lead_days: [7, 1], }) export function EventModal({ defaultDate, onClose, onCreated }: EventModalProps) { const { isDark } = useTheme() const [form, setForm] = useState(initial(defaultDate)) const [saving, setSaving] = useState(false) const [error, setError] = useState(null) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setSaving(true) setError(null) try { await calendarApi.createEvent(form) onCreated() } catch (err) { setError(err instanceof Error ? err.message : 'Anlegen fehlgeschlagen') } finally { setSaving(false) } } const cardClass = isDark ? 'bg-slate-900/95 border-white/20 text-white' : 'bg-white border-black/10 text-slate-900' const inputClass = isDark ? 'bg-white/10 border-white/20 text-white' : 'bg-white border-slate-300 text-slate-900' return (

Neuer Termin

setForm({ ...form, title: e.target.value })} placeholder="z.B. SCHILF: Digitale Tafeln" className={`w-full px-3 py-2 rounded-lg border ${inputClass}`} data-testid="event-title" />
setForm({ ...form, is_school_free: e.target.checked })} className="w-5 h-5" />
setForm({ ...form, start_date: e.target.value })} className={`w-full px-3 py-2 rounded-lg border ${inputClass}`} />
setForm({ ...form, end_date: e.target.value })} className={`w-full px-3 py-2 rounded-lg border ${inputClass}`} />
setForm({ ...form, start_time: e.target.value || null })} className={`w-full px-3 py-2 rounded-lg border ${inputClass}`} />
setForm({ ...form, end_time: e.target.value || null })} className={`w-full px-3 py-2 rounded-lg border ${inputClass}`} />