'use client' import { useEffect, useState } from 'react' import { useTheme } from '@/lib/ThemeContext' import { calendarApi } from '@/lib/schulkalender/api' import type { NotificationLogRow } from '@/app/schulkalender/types' interface NotificationStatusProps { eventId: string } const STATUS_ICON: Record = { sent: '✓', failed: '✗', skipped: '⏱', } export function NotificationStatus({ eventId }: NotificationStatusProps) { const { isDark } = useTheme() const [rows, setRows] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { calendarApi.listEventNotifications(eventId) .then(r => { setRows(r || []); setLoading(false) }) .catch(() => setLoading(false)) }, [eventId]) if (loading || rows.length === 0) return null return (
Erinnerungen
{rows.map((r, i) => ( {STATUS_ICON[r.status]} {r.lead_days === 0 ? 'Heute' : r.lead_days === 1 ? '1 Tag' : `${r.lead_days} Tage`} {' · '}{r.audience === 'parents' ? 'Eltern' : 'Schueler'} {' · '}{r.channel} ))}
) }