'use client' import { useState } from 'react' import type { OCRSession, OCRStats } from '../types' const API_BASE = process.env.NEXT_PUBLIC_KLAUSUR_SERVICE_URL || 'http://localhost:8086' export default function ExportTab({ sessions, selectedSession, setSelectedSession, stats, onError, }: { sessions: OCRSession[] selectedSession: string | null setSelectedSession: (id: string | null) => void stats: OCRStats | null onError: (msg: string) => void }) { const [exportFormat, setExportFormat] = useState<'generic' | 'trocr' | 'llama_vision'>('generic') const [exporting, setExporting] = useState(false) const [exportResult, setExportResult] = useState(null) const handleExport = async () => { setExporting(true) try { const res = await fetch(`${API_BASE}/api/v1/ocr-label/export`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ export_format: exportFormat, session_id: selectedSession, }), }) if (res.ok) { const data = await res.json() setExportResult(data) } else { onError('Export fehlgeschlagen') } } catch (err) { onError('Netzwerkfehler') } finally { setExporting(false) } } return (

Training-Daten exportieren

{exportResult && (

Export-Ergebnis

{exportResult.exported_count} Samples erfolgreich exportiert

Batch: {exportResult.batch_id}

{JSON.stringify(exportResult.samples?.slice(0, 3), null, 2)}
{(exportResult.samples?.length || 0) > 3 && (

... und {exportResult.samples.length - 3} weitere

)}
)}
) }