diff --git a/admin-lehrer/components/ocr-kombi/StepBoxGridReview.tsx b/admin-lehrer/components/ocr-kombi/StepBoxGridReview.tsx index d949162..2255147 100644 --- a/admin-lehrer/components/ocr-kombi/StepBoxGridReview.tsx +++ b/admin-lehrer/components/ocr-kombi/StepBoxGridReview.tsx @@ -33,6 +33,8 @@ export function StepBoxGridReview({ sessionId, onNext }: StepBoxGridReviewProps) loadGrid, saveGrid, updateCellText, + toggleColumnBold, + toggleRowHeader, undo, redo, canUndo, @@ -44,6 +46,10 @@ export function StepBoxGridReview({ sessionId, onNext }: StepBoxGridReviewProps) clearCellSelection, toggleSelectedBold, setCellColor, + deleteColumn, + addColumn, + deleteRow, + addRow, } = useGridEditor(sessionId) const [building, setBuilding] = useState(false) @@ -77,7 +83,6 @@ export function StepBoxGridReview({ sessionId, onNext }: StepBoxGridReviewProps) const data = await res.json().catch(() => ({})) throw new Error(data.detail || `HTTP ${res.status}`) } - // Reload grid to see updated box zones await loadGrid() } catch (e) { setBuildError(e instanceof Error ? e.message : String(e)) @@ -87,18 +92,19 @@ export function StepBoxGridReview({ sessionId, onNext }: StepBoxGridReviewProps) }, [sessionId, loadGrid]) // Handle layout type change for a specific box zone - const changeLayoutType = useCallback(async (zoneIndex: number, layoutType: string) => { - await buildBoxGrids({ [String(zoneIndex)]: layoutType }) + const changeLayoutType = useCallback(async (boxIdx: number, layoutType: string) => { + await buildBoxGrids({ [String(boxIdx)]: layoutType }) }, [buildBoxGrids]) // Auto-build on first load if box zones have no cells useEffect(() => { if (!grid || loading || building) return - const needsBuild = boxZones.some(z => !z.cells || z.cells.length === 0) - if (needsBuild && boxZones.length > 0) { + const needsBuild = boxZones.length === 0 || boxZones.some(z => !z.cells || z.cells.length === 0) + // Only auto-build if we know there are boxes (check structure_result via a quick fetch) + if (needsBuild && sessionId) { buildBoxGrids() } - }, [grid, loading]) // eslint-disable-line react-hooks/exhaustive-deps + }, [grid?.zones?.length, loading]) // eslint-disable-line react-hooks/exhaustive-deps if (loading) { return ( @@ -109,8 +115,8 @@ export function StepBoxGridReview({ sessionId, onNext }: StepBoxGridReviewProps) ) } - // No boxes detected — skip step - if (boxZones.length === 0) { + // No boxes after build attempt — skip step + if (!building && boxZones.length === 0) { return (
📦
@@ -136,7 +142,7 @@ export function StepBoxGridReview({ sessionId, onNext }: StepBoxGridReviewProps)

- 📦 Box-Review ({boxZones.length} {boxZones.length === 1 ? 'Box' : 'Boxen'}) + Box-Review ({boxZones.length} {boxZones.length === 1 ? 'Box' : 'Boxen'})

Eingebettete Boxen prüfen und korrigieren. Layout-Typ kann pro Box angepasst werden. @@ -186,7 +192,7 @@ export function StepBoxGridReview({ sessionId, onNext }: StepBoxGridReviewProps) )} {/* Box zones */} - {boxZones.map((zone) => ( + {boxZones.map((zone, boxIdx) => (

📦
- Box {zone.zone_index + 1} + Box {boxIdx + 1} - {zone.bbox_px.w}×{zone.bbox_px.h}px - {zone.cells?.length ? ` • ${zone.cells.length} Zellen` : ''} + {zone.bbox_px?.w}x{zone.bbox_px?.h}px + {zone.cells?.length ? ` | ${zone.cells.length} Zellen` : ''} + {zone.box_layout_type ? ` | ${LAYOUT_LABELS[zone.box_layout_type as BoxLayoutType] || zone.box_layout_type}` : ''}
@@ -209,7 +216,7 @@ export function StepBoxGridReview({ sessionId, onNext }: StepBoxGridReviewProps)