'use client' import React, { useState } from 'react' import { StepHeader, STEP_EXPLANATIONS } from '@/components/sdk/StepHeader' import { useEscalations } from './_hooks/useEscalations' import { EscalationCard } from './_components/EscalationCard' import { EscalationCreateModal } from './_components/EscalationCreateModal' import { EscalationDetailDrawer } from './_components/EscalationDetailDrawer' import { Escalation } from './_components/types' export default function EscalationsPage() { const [filter, setFilter] = useState('all') const [showCreateModal, setShowCreateModal] = useState(false) const [selectedEscalation, setSelectedEscalation] = useState(null) const { escalations, stats, loading, loadAll } = useEscalations(filter) const criticalCount = stats?.by_priority?.critical ?? 0 const escalatedCount = stats?.by_status?.escalated ?? 0 const openCount = stats?.by_status?.open ?? 0 const activeCount = stats?.active ?? 0 const stepInfo = STEP_EXPLANATIONS['escalations'] return (
Gesamt aktiv
{loading ? '…' : activeCount}
Kritisch
{loading ? '…' : criticalCount}
Eskaliert
{loading ? '…' : escalatedCount}
Offen
{loading ? '…' : openCount}
{criticalCount > 0 && (

{criticalCount} kritische Eskalation(en) erfordern sofortige Aufmerksamkeit

Priorisieren Sie diese Vorfaelle zur Vermeidung von Schaeden.

)}
Filter: {[ { key: 'all', label: 'Alle' }, { key: 'open', label: 'Offen' }, { key: 'in_progress', label: 'In Bearbeitung' }, { key: 'escalated', label: 'Eskaliert' }, { key: 'critical', label: 'Kritisch' }, { key: 'high', label: 'Hoch' }, { key: 'resolved', label: 'Geloest' }, ].map(f => ( ))}
{loading ? (
Lade Eskalationen…
) : (
{escalations .sort((a, b) => { const priorityOrder: Record = { critical: 0, high: 1, medium: 2, low: 3 } const statusOrder: Record = { escalated: 0, open: 1, in_progress: 2, resolved: 3, closed: 4 } const pd = (priorityOrder[a.priority] ?? 9) - (priorityOrder[b.priority] ?? 9) if (pd !== 0) return pd return (statusOrder[a.status] ?? 9) - (statusOrder[b.status] ?? 9) }) .map(esc => ( setSelectedEscalation(esc)} /> ))} {escalations.length === 0 && (

Keine Eskalationen gefunden

Passen Sie den Filter an oder erstellen Sie eine neue Eskalation.

)}
)} {showCreateModal && ( setShowCreateModal(false)} onCreated={loadAll} /> )} {selectedEscalation && ( setSelectedEscalation(null)} onUpdated={loadAll} /> )}
) }