'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 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', 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', header: 'Header', footer: 'Footer', } export function ColumnControls({ columnResult, onRerun, onGroundTruth, onNext, isDetecting }: ColumnControlsProps) { const [gtSaved, setGtSaved] = useState(false) if (!columnResult) return null const columns = columnResult.columns.filter((c: PageRegion) => c.type.startsWith('column')) const headerFooter = columnResult.columns.filter((c: PageRegion) => !c.type.startsWith('column')) 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} 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 ) : ( <> )}
) }