'use client' import React, { useEffect, useRef, useState } from 'react' interface Props { assessmentId: string backendUrl: string // eslint-disable-next-line @typescript-eslint/no-explicit-any onComplete: (result: any) => void onError: (msg: string) => void } export function AssessmentProgress({ assessmentId, backendUrl, onComplete, onError }: Props) { const [progress, setProgress] = useState('Initialisierung...') const [dots, setDots] = useState(0) const pollRef = useRef | null>(null) useEffect(() => { const dotTimer = setInterval(() => setDots(d => (d + 1) % 4), 500) pollRef.current = setInterval(async () => { try { const res = await fetch( `${backendUrl}/api/vendor-compliance/assessments/${assessmentId}`, ) if (!res.ok) return const data = await res.json() if (data.status === 'completed' && data.result) { if (pollRef.current) clearInterval(pollRef.current) clearInterval(dotTimer) onComplete(data.result) return } if (data.status === 'failed') { if (pollRef.current) clearInterval(pollRef.current) clearInterval(dotTimer) onError(data.error || 'Pruefung fehlgeschlagen') return } if (data.progress) { setProgress(data.progress) } } catch { // retry silently } }, 2000) return () => { if (pollRef.current) clearInterval(pollRef.current) clearInterval(dotTimer) } }, [assessmentId, backendUrl, onComplete, onError]) return (

Vertragspruefung laeuft

{progress}{'.'.repeat(dots)}

1 Text extrahieren
2 Checklisten pruefen (L1/L2)
3 Cross-Check zwischen Dokumenten
4 Pruefprotokoll generieren
) }