import { FaTimes } from 'react-icons/fa' import { format } from 'date-fns' export default function StatusHistoryModal({ isOpen, onClose, worksheets, ticket }) { if (!isOpen) return null // Extrahiere Status-Änderungen aus Worksheets const statusHistory = worksheets .filter(ws => ws.oldStatus && ws.newStatus && ws.oldStatus !== ws.newStatus) .map(ws => ({ date: ws.startDate, time: ws.startTime, from: ws.oldStatus, to: ws.newStatus, employee: ws.employeeName || ws.employeeShort || 'Unknown', details: ws.details, wsid: ws.wsid })) .sort((a, b) => { // Sortiere nach Datum und Zeit (älteste zuerst) const dateA = `${a.date} ${a.time || '0000'}` const dateB = `${b.date} ${b.time || '0000'}` return dateA.localeCompare(dateB) }) // Füge aktuellen Status hinzu const currentStatus = ticket?.status || 'Open' return (

Status History - WOID {ticket?.woid || ticket?.$id}

Current Status: {currentStatus}
{statusHistory.length === 0 ? (
No status changes recorded yet.
) : (
{statusHistory.map((entry, index) => (
{entry.date} {entry.time ? `${entry.time.substring(0, 2)}:${entry.time.substring(2, 4)}` : ''}
{entry.from} {entry.to}
by
{entry.employee}
{entry.wsid && (
WSID: {entry.wsid}
)}
{entry.details && (
{entry.details}
)}
))}
)}
) }