b53b36fdc5
- 5 tabs: Schnellanalyse, Website-Scan, Cookie-Test, Vergleich, Login-Test - PDF download button in ScanResult - CompareResult: side-by-side compliance comparison table - AuthTestResult: 5 post-login checks with legal refs - API proxies: /scans/pdf, /compare, /authenticated-scan - Compare: textarea for 2-5 URLs, parallel scanning Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
242 lines
9.9 KiB
TypeScript
242 lines
9.9 KiB
TypeScript
'use client'
|
|
|
|
import React, { useState } from 'react'
|
|
import { TextReference } from './TextReference'
|
|
|
|
interface ServiceInfo {
|
|
name: string
|
|
category: string
|
|
provider: string
|
|
country: string
|
|
eu_adequate: boolean
|
|
requires_consent: boolean
|
|
legal_ref: string
|
|
in_dse: boolean
|
|
status: string
|
|
}
|
|
|
|
interface TextRef {
|
|
found: boolean
|
|
source_url: string
|
|
document_type: string
|
|
section_heading: string
|
|
section_number: string
|
|
parent_section: string
|
|
paragraph_index: number
|
|
original_text: string
|
|
issue: string
|
|
correction_type: string
|
|
correction_text: string
|
|
insert_after: string
|
|
}
|
|
|
|
interface ScanFinding {
|
|
code: string
|
|
severity: string
|
|
text: string
|
|
correction: string
|
|
text_reference: TextRef | null
|
|
}
|
|
|
|
interface ScanData {
|
|
pages_scanned: number
|
|
pages_list: string[]
|
|
services: ServiceInfo[]
|
|
findings: ScanFinding[]
|
|
ai_detected: boolean
|
|
chatbot_detected: boolean
|
|
chatbot_provider: string
|
|
missing_pages: Record<string, number>
|
|
email_status: string
|
|
}
|
|
|
|
const STATUS_ICON: Record<string, { icon: string; color: string }> = {
|
|
ok: { icon: '✓', color: 'text-green-600' },
|
|
undocumented: { icon: '✗', color: 'text-red-600' },
|
|
outdated: { icon: '~', color: 'text-yellow-600' },
|
|
}
|
|
|
|
const SEV_STYLE: Record<string, { bg: string; text: string }> = {
|
|
HIGH: { bg: 'bg-red-50 border-red-200', text: 'text-red-800' },
|
|
MEDIUM: { bg: 'bg-yellow-50 border-yellow-200', text: 'text-yellow-800' },
|
|
LOW: { bg: 'bg-blue-50 border-blue-200', text: 'text-blue-800' },
|
|
}
|
|
|
|
export function ScanResult({ data }: { data: ScanData }) {
|
|
const [expandedCorrection, setExpandedCorrection] = useState<string | null>(null)
|
|
|
|
const undocCount = data.services.filter(s => s.status === 'undocumented').length
|
|
const okCount = data.services.filter(s => s.status === 'ok').length
|
|
const outdatedCount = data.services.filter(s => s.status === 'outdated').length
|
|
const highCount = data.findings.filter(f => f.severity === 'HIGH').length
|
|
|
|
return (
|
|
<div className="space-y-5">
|
|
{/* Summary Bar */}
|
|
<div className="grid grid-cols-4 gap-3">
|
|
<div className="bg-gray-50 rounded-lg p-3 text-center">
|
|
<p className="text-2xl font-bold text-gray-900">{data.pages_scanned}</p>
|
|
<p className="text-xs text-gray-500">Seiten gescannt</p>
|
|
</div>
|
|
<div className="bg-green-50 rounded-lg p-3 text-center">
|
|
<p className="text-2xl font-bold text-green-700">{okCount}</p>
|
|
<p className="text-xs text-gray-500">Dokumentiert</p>
|
|
</div>
|
|
<div className="bg-red-50 rounded-lg p-3 text-center">
|
|
<p className="text-2xl font-bold text-red-700">{undocCount}</p>
|
|
<p className="text-xs text-gray-500">Nicht in DSE</p>
|
|
</div>
|
|
<div className="bg-yellow-50 rounded-lg p-3 text-center">
|
|
<p className="text-2xl font-bold text-yellow-700">{outdatedCount}</p>
|
|
<p className="text-xs text-gray-500">Veraltet</p>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Scanned Pages */}
|
|
{data.pages_list?.length > 0 && (
|
|
<details className="text-sm">
|
|
<summary className="text-gray-600 cursor-pointer hover:text-gray-800">
|
|
{data.pages_scanned} Seiten gescannt — Details anzeigen
|
|
</summary>
|
|
<ul className="mt-2 space-y-1 ml-4">
|
|
{data.pages_list.map((p, i) => {
|
|
const isMissing = data.missing_pages[p]
|
|
return (
|
|
<li key={i} className={`text-xs ${isMissing ? 'text-red-600' : 'text-gray-500'}`}>
|
|
{isMissing ? '✗' : '✓'} {p} {isMissing ? `(HTTP ${data.missing_pages[p]})` : ''}
|
|
</li>
|
|
)
|
|
})}
|
|
</ul>
|
|
</details>
|
|
)}
|
|
|
|
{/* AI / Chatbot Detection */}
|
|
<div className="flex gap-3">
|
|
<span className={`px-3 py-1 rounded-full text-xs font-medium ${data.ai_detected ? 'bg-purple-100 text-purple-800' : 'bg-gray-100 text-gray-600'}`}>
|
|
{data.ai_detected ? 'KI erkannt' : 'Keine KI erkannt'}
|
|
</span>
|
|
<span className={`px-3 py-1 rounded-full text-xs font-medium ${data.chatbot_detected ? 'bg-blue-100 text-blue-800' : 'bg-gray-100 text-gray-600'}`}>
|
|
{data.chatbot_detected ? `Chatbot: ${data.chatbot_provider}` : 'Kein Chatbot'}
|
|
</span>
|
|
</div>
|
|
|
|
{/* Services Table */}
|
|
<div>
|
|
<h4 className="text-sm font-medium text-gray-700 mb-2">Dienstleister-Abgleich (SOLL/IST)</h4>
|
|
<div className="border rounded-lg overflow-hidden">
|
|
<table className="w-full text-sm">
|
|
<thead className="bg-gray-50">
|
|
<tr>
|
|
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">Status</th>
|
|
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">Dienst</th>
|
|
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">Land</th>
|
|
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">EU</th>
|
|
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">In DSE</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody className="divide-y divide-gray-100">
|
|
{data.services.map((s, i) => {
|
|
const st = STATUS_ICON[s.status] || STATUS_ICON.ok
|
|
return (
|
|
<tr key={i} className={s.status === 'undocumented' ? 'bg-red-50' : ''}>
|
|
<td className={`px-3 py-2 font-bold ${st.color}`}>{st.icon}</td>
|
|
<td className="px-3 py-2">
|
|
<span className="font-medium text-gray-900">{s.name}</span>
|
|
<span className="text-gray-400 text-xs ml-2">{s.category}</span>
|
|
</td>
|
|
<td className="px-3 py-2 text-gray-600">{s.country}</td>
|
|
<td className="px-3 py-2">{s.eu_adequate ? '✓' : '✗'}</td>
|
|
<td className="px-3 py-2">{s.in_dse ? 'Ja' : <span className="text-red-600 font-medium">Nein</span>}</td>
|
|
</tr>
|
|
)
|
|
})}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Findings */}
|
|
{data.findings.length > 0 && (
|
|
<div>
|
|
<h4 className="text-sm font-medium text-gray-700 mb-2">
|
|
Findings ({data.findings.length}, davon {highCount} kritisch)
|
|
</h4>
|
|
<div className="space-y-2">
|
|
{data.findings.map((f, i) => {
|
|
const sev = SEV_STYLE[f.severity] || SEV_STYLE.MEDIUM
|
|
const isExpanded = expandedCorrection === f.code
|
|
return (
|
|
<div key={i} className={`border rounded-lg p-3 ${sev.bg}`}>
|
|
<div className="flex items-start gap-2">
|
|
<span className={`text-xs font-bold px-2 py-0.5 rounded ${sev.text} bg-white`}>
|
|
{f.severity}
|
|
</span>
|
|
<p className="text-sm text-gray-800 flex-1">{f.text}</p>
|
|
</div>
|
|
{/* Text Reference (original text + position + correction) */}
|
|
{f.text_reference && (
|
|
<TextReference ref={f.text_reference} correction={f.correction} />
|
|
)}
|
|
{/* Fallback: correction without text reference */}
|
|
{!f.text_reference && f.correction && (
|
|
<div className="mt-2">
|
|
<button
|
|
onClick={() => setExpandedCorrection(isExpanded ? null : f.code)}
|
|
className="text-xs text-purple-600 hover:text-purple-800 font-medium"
|
|
>
|
|
{isExpanded ? '▼ Korrekturvorschlag ausblenden' : '▶ Korrekturvorschlag anzeigen'}
|
|
</button>
|
|
{isExpanded && (
|
|
<div className="mt-2 bg-white border border-gray-200 rounded-lg p-3 relative">
|
|
<pre className="text-xs text-gray-700 whitespace-pre-wrap font-sans">{f.correction}</pre>
|
|
<button
|
|
onClick={() => navigator.clipboard.writeText(f.correction)}
|
|
className="absolute top-2 right-2 text-xs bg-gray-100 hover:bg-gray-200 px-2 py-1 rounded"
|
|
title="Kopieren"
|
|
>
|
|
Kopieren
|
|
</button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
</div>
|
|
)}
|
|
{/* PDF Export Button */}
|
|
<div className="pt-4 border-t flex gap-3">
|
|
<button
|
|
onClick={async () => {
|
|
try {
|
|
const res = await fetch('/api/sdk/v1/agent/scans/pdf', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ url: '', scan_type: 'scan', analysis_mode: 'post_launch', result: data }),
|
|
})
|
|
if (res.ok) {
|
|
const blob = await res.blob()
|
|
const url = URL.createObjectURL(blob)
|
|
const a = document.createElement('a')
|
|
a.href = url
|
|
a.download = 'compliance-report.pdf'
|
|
a.click()
|
|
URL.revokeObjectURL(url)
|
|
}
|
|
} catch (e) { console.error('PDF export failed:', e) }
|
|
}}
|
|
className="flex items-center gap-2 px-4 py-2 text-sm font-medium text-purple-700 bg-purple-50 border border-purple-200 rounded-lg hover:bg-purple-100 transition-colors"
|
|
>
|
|
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
|
</svg>
|
|
PDF herunterladen
|
|
</button>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|