'use client' import React, { useState } from 'react' interface TextRef { found: boolean source_url: string document_type: string section_heading: string section_number: string parent_section: string paragraph_index: number original_text: string issue: string correction_type: string correction_text: string insert_after: string } const ISSUE_LABELS: Record = { missing: { label: 'Fehlt in der DSE', color: 'text-red-700 bg-red-50' }, incomplete: { label: 'Unvollstaendig', color: 'text-yellow-700 bg-yellow-50' }, incorrect: { label: 'Fehlerhaft', color: 'text-orange-700 bg-orange-50' }, } const CORRECTION_LABELS: Record = { insert: 'Neuen Abschnitt einfuegen', append: 'Am Ende des Absatzes ergaenzen', replace: 'Absatz ersetzen', } export function TextReference({ ref, correction }: { ref: TextRef; correction?: string }) { const [showCorrection, setShowCorrection] = useState(false) const issue = ISSUE_LABELS[ref.issue] || null const correctionText = correction || ref.correction_text return (
{/* Original Text Block */}

📄 Originaltextblock:

{ref.found ? (

{ref.original_text || '(Textinhalt konnte nicht extrahiert werden)'}

) : (

Nicht vorhanden — Eintrag fehlt in der {ref.document_type}.

)}
{/* Position */}

📍 Position:

{ref.found ? ( <> {ref.section_heading || 'Abschnitt unbekannt'} {ref.section_number && (Nr. {ref.section_number})} {ref.parent_section && in: {ref.parent_section}} {ref.paragraph_index > 0 && | Absatz {ref.paragraph_index}} ) : ref.insert_after ? ( {CORRECTION_LABELS[ref.correction_type] || 'Einfuegen'} nach Abschnitt "{ref.insert_after}" ) : ( Neuen Abschnitt in der {ref.document_type} anlegen )} {ref.source_url && (
in: {ref.source_url}
)}
{/* Correction */} {correctionText && (
{showCorrection && (
{issue && ( {CORRECTION_LABELS[ref.correction_type] || issue.label} )}
{correctionText}
)}
)}
) }