'use client'
/**
* DocResultView — EIN Dokument-Prüfergebnis der HAUPT-Engine als saubere,
* immer-offene Pflichtangaben-Tabelle: Verdikt + Gruppen + extrahierte Texte
* (matched_text) pro Prüfpunkt.
*
* Quelle = result.results[doc] (die genaue Haupt-Doc-Check-Engine), NICHT
* der v3-Agent. Zeigt menschliche Labels + gefundene Snippets, keine internen
* IDs. Wiederverwendet die Render-Bausteine aus ChecklistView.
*/
import React from 'react'
import {
CheckIcon,
type DocResult,
groupChecks,
SCENARIO_LABELS,
} from './ChecklistView'
function Snippet({ text }: { text: string }) {
return (
„…{text}…"
)
}
function ScoreBar({ label, pct, blue }: { label: string; pct: number; blue?: boolean }) {
const color = blue
? pct >= 80 ? 'bg-blue-400' : 'bg-blue-300'
: pct === 100 ? 'bg-green-500' : pct >= 50 ? 'bg-yellow-500' : 'bg-red-500'
return (
)
}
export function DocResultView({ doc }: { doc: DocResult }) {
if (doc.error) {
return (
{doc.error}
)
}
const grouped = groupChecks(doc.checks)
const l1 = doc.checks.filter(c => (c.level ?? 1) === 1)
const l1Score = l1.filter(c => c.severity !== 'INFO')
const l1Passed = l1Score.filter(c => c.passed).length
const l2 = doc.checks.filter(c => (c.level ?? 1) === 2 && !c.skipped)
const l2Passed = l2.filter(c => c.passed).length
const sc = doc.scenario ? SCENARIO_LABELS[doc.scenario] : null
return (
{/* Verdikt-Kopf */}
{sc && (
{sc.label}
)}
{l1Passed}/{l1Score.length} Pflichtangaben
{l2.length > 0 && <>, {l2Passed}/{l2.length} Detailprüfungen>}
{l2.length > 0 && (
)}
{/* Pflichtangaben-Tabelle */}
{grouped.map(g => {
const l1Info = g.check.severity === 'INFO' && !g.check.passed
return (
{g.check.label}
{g.check.passed && g.check.matched_text && g.children.length === 0 && (
)}
{!g.check.passed && g.check.hint && (
{g.check.hint}
)}
{g.children.length > 0 && (
{g.children.map(ch => {
const chInfo = ch.severity === 'INFO' && !ch.passed && !ch.skipped
return (
{ch.label}{ch.skipped && ' (übersprungen)'}
{ch.passed && ch.matched_text &&
}
{!ch.passed && !ch.skipped && ch.hint && (
{ch.hint}
)}
)
})}
)}
)
})}
{doc.word_count > 0 && (
{doc.word_count} Wörter analysiert
)}
)
}