'use client' import { useTheme } from '@/lib/ThemeContext' import { calendarApi } from '@/lib/schulkalender/api' import type { PublicEvent, SchoolEvent } from '@/app/schulkalender/types' import { EVENT_TYPE_COLOR, EVENT_TYPE_LABEL } from '@/app/schulkalender/types' import { NotificationStatus } from './NotificationStatus' interface DayDetailProps { iso: string holidays: PublicEvent[] events: SchoolEvent[] onClose: () => void onDeleted: () => void } export function DayDetail({ iso, holidays, events, onClose, onDeleted }: DayDetailProps) { const { isDark } = useTheme() const handleDelete = async (id: string) => { if (!confirm('Termin wirklich loeschen?')) return try { await calendarApi.deleteEvent(id) onDeleted() } catch { // best-effort } } const cardClass = isDark ? 'bg-slate-900/95 border-white/20 text-white' : 'bg-white border-black/10 text-slate-900' const dayHolidays = holidays.filter(h => iso >= h.start_date && iso <= h.end_date) const dayEvents = events.filter(e => iso >= e.start_date && iso <= e.end_date) const formattedDate = new Date(iso).toLocaleDateString('de-DE', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric', }) return (

{formattedDate}

{dayHolidays.length === 0 && dayEvents.length === 0 && (

Keine Eintraege fuer diesen Tag.

)} {dayHolidays.length > 0 && (

Bundesweite Eintraege

{dayHolidays.map(h => (
{h.name_de}
{h.event_type === 'public_holiday' ? 'Feiertag' : 'Schulferien'} · {h.start_date}{h.start_date !== h.end_date ? ` – ${h.end_date}` : ''}
))}
)} {dayEvents.length > 0 && (

Schul-Termine

{dayEvents.map(e => (
{e.title}
{EVENT_TYPE_LABEL[e.event_type]} {e.start_time && ` · ${e.start_time}${e.end_time ? `–${e.end_time}` : ''}`} {e.is_school_free && ' · unterrichtsfrei'}
{e.description &&
{e.description}
}
{e.visible_to_parents && '👨‍👩‍👧 sichtbar fuer Eltern'} {e.notify_parents && ' · 📧 Eltern erinnern'} {e.notify_students && ' · 💬 Schueler erinnern'}
{(e.notify_parents || e.notify_students) && ( )}
))}
)}
) }