'use client' import { useState, useEffect, useCallback } from 'react' import { OnboardingReport, api, CLASSIFICATION_LABELS } from '../_types' import { ComplianceRing } from './ComplianceRing' export function ReportTab() { const [reports, setReports] = useState([]) const [activeReport, setActiveReport] = useState(null) const [loading, setLoading] = useState(true) const [generating, setGenerating] = useState(false) const loadReports = useCallback(async () => { setLoading(true) try { const data = await api('reports') setReports(data || []) if (data?.length > 0 && !activeReport) { const detail = await api(`reports/${data[0].id}`) setActiveReport(detail) } } catch { /* ignore */ } setLoading(false) }, [activeReport]) useEffect(() => { loadReports() }, [loadReports]) const handleGenerate = async () => { setGenerating(true) try { const result = await api('reports/generate', { method: 'POST', body: JSON.stringify({}), }) setActiveReport(result) loadReports() } catch { /* ignore */ } setGenerating(false) } const handleSelectReport = async (id: string) => { const detail = await api(`reports/${id}`) setActiveReport(detail) } return (

Onboarding-Report

{/* Report selector */} {reports.length > 1 && (
{reports.map(r => ( ))}
)} {loading ? (
Laden...
) : !activeReport ? (

Kein Report vorhanden

Fuehren Sie zuerst einen Crawl durch und generieren Sie dann einen Report.

) : (
{/* Score + Stats */}
{activeReport.total_documents_found}
Dokumente gefunden
{Object.keys(activeReport.classification_breakdown || {}).length}
Kategorien abgedeckt
{(activeReport.gaps || []).length}
Luecken identifiziert
{/* Classification breakdown */}

Dokumenten-Verteilung

{Object.entries(activeReport.classification_breakdown || {}).map(([cat, count]) => { const cls = CLASSIFICATION_LABELS[cat] || CLASSIFICATION_LABELS['Sonstiges'] return ( {cls.label}: {count as number} ) })} {Object.keys(activeReport.classification_breakdown || {}).length === 0 && ( Keine Dokumente klassifiziert )}
{/* Gap summary */} {activeReport.gap_summary && (
{activeReport.gap_summary.critical}
Kritisch
{activeReport.gap_summary.high}
Hoch
{activeReport.gap_summary.medium}
Mittel
)} {/* Gap details */} {(activeReport.gaps || []).length > 0 && (

Compliance-Luecken

{activeReport.gaps.map((gap) => (
{gap.category}

{gap.description}

{gap.severity}
Regulierung: {gap.regulation} | Aktion: {gap.requiredAction}
))}
)}
)}
) }