'use client' import { useState } from 'react' import type { ColumnResult, ColumnGroundTruth, PageRegion } from '@/app/(admin)/ai/ocr-pipeline/types' interface ColumnControlsProps { columnResult: ColumnResult | null onRerun: () => void onManualMode: () => void onGroundTruth: (gt: ColumnGroundTruth) => void onNext: () => void isDetecting: boolean } const TYPE_COLORS: Record = { column_en: 'bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400', column_de: 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400', column_example: 'bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400', column_text: 'bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-400', page_ref: 'bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400', column_marker: 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400', header: 'bg-gray-100 text-gray-600 dark:bg-gray-700/50 dark:text-gray-400', footer: 'bg-gray-100 text-gray-600 dark:bg-gray-700/50 dark:text-gray-400', } const TYPE_LABELS: Record = { column_en: 'EN', column_de: 'DE', column_example: 'Beispiel', column_text: 'Text', page_ref: 'Seite', column_marker: 'Marker', header: 'Header', footer: 'Footer', } const METHOD_LABELS: Record = { content: 'Inhalt', position_enhanced: 'Position', position_fallback: 'Fallback', } export function ColumnControls({ columnResult, onRerun, onManualMode, onGroundTruth, onNext, isDetecting }: ColumnControlsProps) { const [gtSaved, setGtSaved] = useState(false) if (!columnResult) return null const columns = columnResult.columns.filter((c: PageRegion) => c.type.startsWith('column') || c.type === 'page_ref') const headerFooter = columnResult.columns.filter((c: PageRegion) => !c.type.startsWith('column') && c.type !== 'page_ref') const handleGt = (isCorrect: boolean) => { onGroundTruth({ is_correct: isCorrect }) setGtSaved(true) } return (
{/* Summary */}
{columns.length} Spalten erkannt {columnResult.duration_seconds > 0 && ( ({columnResult.duration_seconds}s) )}
{/* Column list */}
{columns.map((col: PageRegion, i: number) => (
{TYPE_LABELS[col.type] || col.type} {col.classification_confidence != null && col.classification_confidence < 1.0 && ( {Math.round(col.classification_confidence * 100)}% )} {col.classification_method && ( ({METHOD_LABELS[col.classification_method] || col.classification_method}) )} x={col.x} y={col.y} {col.width}x{col.height}px
))} {headerFooter.map((r: PageRegion, i: number) => (
{TYPE_LABELS[r.type] || r.type} x={r.x} y={r.y} {r.width}x{r.height}px
))}
{/* Ground Truth + Navigation */}
Spalten korrekt? {gtSaved ? ( Gespeichert ) : ( <> )}
) }