'use client' import { useState, useCallback } from 'react' import { useRouter } from 'next/navigation' import { useSDK } from '@/lib/sdk' import type { ImportedDocument, ImportedDocumentType, GapAnalysis, GapItem } from '@/lib/sdk/types' // ============================================================================= // DOCUMENT TYPE OPTIONS // ============================================================================= const DOCUMENT_TYPES: { value: ImportedDocumentType; label: string; icon: string }[] = [ { value: 'DSFA', label: 'Datenschutz-Folgenabschaetzung (DSFA)', icon: '📄' }, { value: 'TOM', label: 'Technisch-organisatorische Massnahmen (TOMs)', icon: '🔒' }, { value: 'VVT', label: 'Verarbeitungsverzeichnis (VVT)', icon: '📊' }, { value: 'AGB', label: 'Allgemeine Geschaeftsbedingungen (AGB)', icon: '📜' }, { value: 'PRIVACY_POLICY', label: 'Datenschutzerklaerung', icon: '🔐' }, { value: 'COOKIE_POLICY', label: 'Cookie-Richtlinie', icon: '🍪' }, { value: 'RISK_ASSESSMENT', label: 'Risikobewertung', icon: '⚠️' }, { value: 'AUDIT_REPORT', label: 'Audit-Bericht', icon: '✅' }, { value: 'OTHER', label: 'Sonstiges Dokument', icon: '📎' }, ] // ============================================================================= // UPLOAD ZONE // ============================================================================= interface UploadedFile { id: string file: File type: ImportedDocumentType status: 'pending' | 'uploading' | 'analyzing' | 'complete' | 'error' progress: number error?: string } function UploadZone({ onFilesAdded, isDisabled, }: { onFilesAdded: (files: File[]) => void isDisabled: boolean }) { const [isDragging, setIsDragging] = useState(false) const handleDragOver = useCallback((e: React.DragEvent) => { e.preventDefault() if (!isDisabled) setIsDragging(true) }, [isDisabled]) const handleDragLeave = useCallback((e: React.DragEvent) => { e.preventDefault() setIsDragging(false) }, []) const handleDrop = useCallback( (e: React.DragEvent) => { e.preventDefault() setIsDragging(false) if (isDisabled) return const files = Array.from(e.dataTransfer.files).filter( f => f.type === 'application/pdf' || f.type.startsWith('image/') ) if (files.length > 0) { onFilesAdded(files) } }, [onFilesAdded, isDisabled] ) const handleFileSelect = useCallback( (e: React.ChangeEvent) => { if (e.target.files && !isDisabled) { const files = Array.from(e.target.files) onFilesAdded(files) } }, [onFilesAdded, isDisabled] ) return (

{isDragging ? 'Dateien hier ablegen' : 'Dokumente hochladen'}

Ziehen Sie PDF-Dateien hierher oder klicken Sie zum Auswaehlen

Unterstuetzte Formate: PDF JPG PNG
) } // ============================================================================= // FILE LIST // ============================================================================= function FileItem({ file, onTypeChange, onRemove, }: { file: UploadedFile onTypeChange: (id: string, type: ImportedDocumentType) => void onRemove: (id: string) => void }) { return (
{/* File Icon */}
{/* File Info */}

{file.file.name}

{(file.file.size / 1024 / 1024).toFixed(2)} MB

{/* Type Selector */} {/* Status / Actions */} {file.status === 'pending' && ( )} {file.status === 'uploading' && (
{file.progress}%
)} {file.status === 'analyzing' && (
Analysiere...
)} {file.status === 'complete' && (
Fertig
)} {file.status === 'error' && (
{file.error || 'Fehler'}
)}
) } // ============================================================================= // GAP ANALYSIS PREVIEW // ============================================================================= function GapAnalysisPreview({ analysis }: { analysis: GapAnalysis }) { return (
📊

Gap-Analyse Ergebnis

{analysis.totalGaps} Luecken in {analysis.gaps.length} Kategorien gefunden

{/* Summary Stats */}
{analysis.criticalGaps}
Kritisch
{analysis.highGaps}
Hoch
{analysis.mediumGaps}
Mittel
{analysis.lowGaps}
Niedrig
{/* Gap List */}
{analysis.gaps.slice(0, 5).map((gap: GapItem) => (
{gap.category}

{gap.description}

{gap.severity}
Regulierung: {gap.regulation} | Aktion: {gap.requiredAction}
))} {analysis.gaps.length > 5 && (

+ {analysis.gaps.length - 5} weitere Luecken

)}
) } // ============================================================================= // MAIN PAGE // ============================================================================= export default function ImportPage() { const router = useRouter() const { state, addImportedDocument, setGapAnalysis, dispatch } = useSDK() const [files, setFiles] = useState([]) const [isAnalyzing, setIsAnalyzing] = useState(false) const [analysisResult, setAnalysisResult] = useState(null) const handleFilesAdded = useCallback((newFiles: File[]) => { const uploadedFiles: UploadedFile[] = newFiles.map(file => ({ id: `file-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, file, type: 'OTHER' as ImportedDocumentType, status: 'pending' as const, progress: 0, })) setFiles(prev => [...prev, ...uploadedFiles]) }, []) const handleTypeChange = useCallback((id: string, type: ImportedDocumentType) => { setFiles(prev => prev.map(f => (f.id === id ? { ...f, type } : f))) }, []) const handleRemove = useCallback((id: string) => { setFiles(prev => prev.filter(f => f.id !== id)) }, []) const handleAnalyze = async () => { if (files.length === 0) return setIsAnalyzing(true) // Simulate upload and analysis for (let i = 0; i < files.length; i++) { const file = files[i] // Update to uploading setFiles(prev => prev.map(f => (f.id === file.id ? { ...f, status: 'uploading' as const } : f))) // Simulate upload progress for (let p = 0; p <= 100; p += 20) { await new Promise(resolve => setTimeout(resolve, 100)) setFiles(prev => prev.map(f => (f.id === file.id ? { ...f, progress: p } : f))) } // Update to analyzing setFiles(prev => prev.map(f => (f.id === file.id ? { ...f, status: 'analyzing' as const } : f))) // Simulate analysis await new Promise(resolve => setTimeout(resolve, 1000)) // Create imported document const doc: ImportedDocument = { id: file.id, name: file.file.name, type: file.type, fileUrl: URL.createObjectURL(file.file), uploadedAt: new Date(), analyzedAt: new Date(), analysisResult: { detectedType: file.type, confidence: 0.85 + Math.random() * 0.15, extractedEntities: ['DSGVO', 'AI Act', 'Personenbezogene Daten'], gaps: [], recommendations: ['KI-spezifische Klauseln ergaenzen', 'AI Act Anforderungen pruefen'], }, } addImportedDocument(doc) // Update to complete setFiles(prev => prev.map(f => (f.id === file.id ? { ...f, status: 'complete' as const } : f))) } // Generate mock gap analysis const gaps: GapItem[] = [ { id: 'gap-1', category: 'AI Act Compliance', description: 'Keine Risikoklassifizierung fuer KI-Systeme vorhanden', severity: 'CRITICAL', regulation: 'EU AI Act Art. 6', requiredAction: 'Risikoklassifizierung durchfuehren', relatedStepId: 'ai-act', }, { id: 'gap-2', category: 'Transparenz', description: 'Informationspflichten bei automatisierten Entscheidungen fehlen', severity: 'HIGH', regulation: 'DSGVO Art. 13, 14, 22', requiredAction: 'Datenschutzerklaerung erweitern', relatedStepId: 'einwilligungen', }, { id: 'gap-3', category: 'TOMs', description: 'KI-spezifische technische Massnahmen nicht dokumentiert', severity: 'MEDIUM', regulation: 'DSGVO Art. 32', requiredAction: 'TOMs um KI-Aspekte erweitern', relatedStepId: 'tom', }, { id: 'gap-4', category: 'VVT', description: 'KI-basierte Verarbeitungstaetigkeiten nicht erfasst', severity: 'HIGH', regulation: 'DSGVO Art. 30', requiredAction: 'VVT aktualisieren', relatedStepId: 'vvt', }, { id: 'gap-5', category: 'Aufsicht', description: 'Menschliche Aufsicht nicht definiert', severity: 'MEDIUM', regulation: 'EU AI Act Art. 14', requiredAction: 'Aufsichtsprozesse definieren', relatedStepId: 'controls', }, ] const gapAnalysis: GapAnalysis = { id: `analysis-${Date.now()}`, createdAt: new Date(), totalGaps: gaps.length, criticalGaps: gaps.filter(g => g.severity === 'CRITICAL').length, highGaps: gaps.filter(g => g.severity === 'HIGH').length, mediumGaps: gaps.filter(g => g.severity === 'MEDIUM').length, lowGaps: gaps.filter(g => g.severity === 'LOW').length, gaps, recommendedPackages: ['analyse', 'dokumentation'], } setAnalysisResult(gapAnalysis) setGapAnalysis(gapAnalysis) setIsAnalyzing(false) // Mark step as complete dispatch({ type: 'COMPLETE_STEP', payload: 'import' }) } const handleContinue = () => { router.push('/sdk/screening') } // Redirect if not existing customer if (state.customerType === 'new') { router.push('/sdk') return null } return (
{/* Header */}

Dokumente importieren

Laden Sie Ihre bestehenden Compliance-Dokumente hoch. Unsere KI analysiert sie und identifiziert Luecken fuer KI-Compliance.

{/* Upload Zone */} {/* File List */} {files.length > 0 && (

{files.length} Dokument(e)

{!isAnalyzing && !analysisResult && ( )}
{files.map(file => ( ))}
)} {/* Analyze Button */} {files.length > 0 && !analysisResult && (
)} {/* Analysis Result */} {analysisResult && } {/* Continue Button */} {analysisResult && (

Die Gap-Analyse wurde gespeichert. Sie koennen jetzt mit dem Compliance-Assessment fortfahren.

)}
) }