'use client' import React, { useState } from 'react' import { useParams } from 'next/navigation' import { useBenchmark } from './_hooks/useBenchmark' import { GTImportForm } from './_components/GTImportForm' import { HazardComparisonTable } from './_components/HazardComparisonTable' import { CategoryBreakdown } from './_components/CategoryBreakdown' export default function BenchmarkPage() { const { projectId } = useParams<{ projectId: string }>() const { result, gtLoaded, gtEntryCount, loading, error, importGT, runBenchmark } = useBenchmark(projectId) const [gtProjectId, setGtProjectId] = useState('') // Only count matches >= 50% as real coverage const realMatchCount = result ? (result.matched_pairs?.filter(m => m.match_score >= 0.5).length || 0) : 0 const coveragePct = result ? Math.round(realMatchCount * 100 / Math.max(result.total_gt, 1)) : 0 const measurePct = result ? Math.round(result.measure_coverage * 100) : 0 return (
{/* Header */}

Ground Truth Benchmark

Vergleich der Engine-Ergebnisse mit einer professionellen Risikobeurteilung

{error && (
{error}
)} {/* GT Import or Cross-Project Reference */}

Benchmark ausfuehren

GT aus diesem Projekt verwenden, oder eine Projekt-ID mit importierter GT angeben.

setGtProjectId(e.target.value)} placeholder="GT-Projekt-ID (optional — leer = dieses Projekt)" className="w-full text-xs border border-gray-300 dark:border-gray-600 rounded-md px-3 py-2 bg-gray-50 dark:bg-gray-900" />
{gtLoaded && !result && (
{gtEntryCount} GT-Eintraege geladen. Klicke "Benchmark starten".
)}
{/* Results */} {result && ( <> {/* Score Cards */}
= 50% Match)`} color={coveragePct >= 80 ? 'green' : coveragePct >= 50 ? 'yellow' : 'red'} /> = 80 ? 'green' : measurePct >= 50 ? 'yellow' : 'red'} />
{/* Category Breakdown */} {/* Hazard Comparison Table */} {/* Business Impact */}

Business Impact

2,5 Tage
Manueller Aufwand
{(coveragePct / 100 * 2.5).toFixed(1)} Tage
Eingespart bei {coveragePct}% Coverage
{Math.round(coveragePct / 100 * 2.5 * 8 * 100)} EUR
Einsparung (100 EUR/h)
)}
) } function ScoreCard({ label, value, sub, color }: { label: string; value: string; sub: string color: 'green' | 'yellow' | 'red' | 'gray' }) { const colors = { green: 'border-green-200 dark:border-green-800', yellow: 'border-yellow-200 dark:border-yellow-800', red: 'border-red-200 dark:border-red-800', gray: 'border-gray-200 dark:border-gray-700', } const textColors = { green: 'text-green-600', yellow: 'text-yellow-600', red: 'text-red-600', gray: 'text-gray-900 dark:text-white', } return (
{value}
{label}
{sub}
) }