'use client' import { useState, useEffect } from 'react' import { ProcessTask, HistoryEntry, API, CATEGORY_LABELS, CATEGORY_COLORS, PRIORITY_LABELS, PRIORITY_COLORS, STATUS_LABELS, STATUS_COLORS, FREQUENCY_LABELS, formatDate, dueLabel, dueLabelColor, } from './types' export function TaskDetailModal({ task, onClose, onComplete, onSkip, onEdit, onDelete, }: { task: ProcessTask onClose: () => void onComplete: (task: ProcessTask) => void onSkip: (task: ProcessTask) => void onEdit: (task: ProcessTask) => void onDelete: (id: string) => Promise }) { const [history, setHistory] = useState([]) const [loadingHistory, setLoadingHistory] = useState(true) useEffect(() => { loadHistory() }, [task.id]) // eslint-disable-line react-hooks/exhaustive-deps const loadHistory = async () => { try { const res = await fetch(`${API}/${task.id}/history`) if (res.ok) { const data = await res.json(); setHistory(data.history || []) } } catch { /* ignore */ } setLoadingHistory(false) } const handleDelete = async () => { if (!confirm('Aufgabe wirklich loeschen?')) return await onDelete(task.id) onClose() } return (
e.target === e.currentTarget && onClose()}>
{CATEGORY_LABELS[task.category] || task.category} {PRIORITY_LABELS[task.priority]} {STATUS_LABELS[task.status]}

{task.title}

{task.task_code}

{task.description &&

{task.description}

}
Frequenz

{FREQUENCY_LABELS[task.frequency] || task.frequency}

Faellig

{task.next_due_date ? `${formatDate(task.next_due_date)} (${dueLabel(task.next_due_date)})` : '\u2014'}

Zustaendig

{task.assigned_to || '\u2014'}

Team

{task.responsible_team || '\u2014'}

{task.linked_module && (
Modul

{task.linked_module}

)} {task.last_completed_at && (
Zuletzt erledigt

{formatDate(task.last_completed_at)}

)}
{task.notes && (
Notizen

{task.notes}

)}

Verlauf

{loadingHistory ? (
) : history.length === 0 ? (

Noch keine Eintraege

) : (
{history.map(h => (
{h.status === 'completed' ? 'Erledigt' : 'Uebersprungen'}

{formatDate(h.completed_at)} {h.completed_by ? `von ${h.completed_by}` : ''}

{h.result &&

{h.result}

} {h.notes &&

{h.notes}

}
))}
)}
{task.status !== 'completed' && ( <> )}
) }