'use client'
import { useState } from 'react'
import type { DewarpResult, DewarpDetection } from '@/app/(admin)/ai/ocr-kombi/types'
import { METHOD_LABELS } from './dewarp-constants'
import { ConfBar } from './ConfBar'
interface DewarpSummaryBannerProps {
dewarpResult: DewarpResult
showGrid: boolean
onToggleGrid: () => void
}
export function DewarpSummaryBanner({ dewarpResult, showGrid, onToggleGrid }: DewarpSummaryBannerProps) {
const detections = dewarpResult.detections || []
const wasRejected = dewarpResult.method_used === 'none' && detections.length > 0
const wasApplied = dewarpResult.method_used !== 'none' && dewarpResult.method_used !== 'manual' && dewarpResult.method_used !== 'manual_combined'
const [showDetails, setShowDetails] = useState(false)
return (
{/* Status line */}
{wasRejected ? '\u26A0\uFE0F' : wasApplied ? '\u2705' : '\u2796'}
{wasRejected
? 'Quality Gate: Korrektur verworfen (Projektion nicht verbessert)'
: wasApplied
? `Korrektur angewendet: ${dewarpResult.shear_degrees.toFixed(2)}\u00B0`
: dewarpResult.method_used === 'manual' || dewarpResult.method_used === 'manual_combined'
? `Manuelle Korrektur: ${dewarpResult.shear_degrees.toFixed(2)}\u00B0`
: 'Keine Korrektur noetig'}
{/* Key metrics */}
Scherung:{' '}
{dewarpResult.shear_degrees.toFixed(2)}\u00B0
Methode:{' '}
{dewarpResult.method_used.includes('+')
? `Ensemble (${dewarpResult.method_used.split('+').map(m => METHOD_LABELS[m] || m).join(' + ')})`
: METHOD_LABELS[dewarpResult.method_used] || dewarpResult.method_used}
Konfidenz:
{/* Toggles row */}
{detections.length > 0 && (
)}
{/* Detailed detections */}
{showDetails && detections.length > 0 && (
Einzelne Detektoren:
{detections.map((d: DewarpDetection) => {
const isUsed = dewarpResult.method_used.includes(d.method)
const aboveThreshold = d.confidence >= 0.5
return (
{isUsed ? '\u2713' : aboveThreshold ? '\u2012' : '\u2717'}
{METHOD_LABELS[d.method] || d.method}
{d.shear_degrees.toFixed(2)}\u00B0
{!aboveThreshold && (
(unter Schwelle)
)}
)
})}
{wasRejected && (
Die Korrektur wurde verworfen, weil die horizontale Projektions-Varianz nach Anwendung nicht besser war als vorher.
)}
)}
)
}