'use client' import React, { useState, useCallback } from 'react' import { DocumentUploader } from './_components/DocumentUploader' import { AssessmentProgress } from './_components/AssessmentProgress' import { PruefprotokollView } from './_components/PruefprotokollView' type View = 'upload' | 'progress' | 'result' interface AssessmentResult { vendor_name: string documents: DocumentResult[] findings: Finding[] overall_score: number category_scores: Record cross_check_findings: CrossCheckFinding[] report_html: string checked_at: string } interface DocumentResult { label: string url: string doc_type: string word_count: number completeness_pct: number correctness_pct: number checks: Check[] findings_count: number error: string } interface Check { id: string label: string passed: boolean severity: string level: number parent: string | null skipped: boolean hint: string matched_text: string } interface Finding { id: string category: string severity: string type: string title: string description: string recommendation: string document_label: string document_type: string } interface CrossCheckFinding { id: string label: string severity: string hint: string } const BACKEND_URL = process.env.NEXT_PUBLIC_COMPLIANCE_API_URL || '' export default function VendorAssessmentPage() { const [view, setView] = useState('upload') const [assessmentId, setAssessmentId] = useState('') const [result, setResult] = useState(null) const [error, setError] = useState('') const handleStartAssessment = useCallback(async ( vendorName: string, documents: Array<{ doc_type: string; label: string; url: string }>, ) => { setError('') try { const res = await fetch(`${BACKEND_URL}/api/vendor-compliance/assessments`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ vendor_name: vendorName, documents }), }) if (!res.ok) throw new Error(await res.text()) const data = await res.json() setAssessmentId(data.assessment_id) setView('progress') } catch (e) { setError(e instanceof Error ? e.message : 'Fehler beim Starten') } }, []) const handleComplete = useCallback((data: AssessmentResult) => { setResult(data) setView('result') }, []) const handleReset = useCallback(() => { setView('upload') setAssessmentId('') setResult(null) setError('') }, []) return (
{/* Header */}

Vertragspruefung

Automatisierte Pruefung von Auftragsverarbeitungsvertraegen gem. Art. 28 DSGVO

{error && (

{error}

)} {view === 'upload' && ( )} {view === 'progress' && assessmentId && ( { setError(msg); setView('upload') }} /> )} {view === 'result' && result && ( )}
) }