feat(agent): /sdk/agent auf Compliance-Check + Snapshot-Historie reduzieren
- Tabs Website-Scan (nie funktioniert), Banner-Check, Agent-Test entfernt; Tab-Leiste weg, da nur noch Compliance-Check übrig. - Unter dem Compliance-Check jetzt die Snapshot-Historie (neuer SnapshotHistoryList): neuester oben + farblich markiert, Klick → Detail- Seite mit den Ergebnissen. Macht /sdk/agent/snapshots erreichbar. - ComplianceCheckTab zeigt nach dem Lauf keine Inline-Ergebnisse mehr, sondern einen Hinweis auf die Historie (onComplete refresht sie). - Tote Komponenten gelöscht (ScanResult/BannerCheckTab/AgentTestTab). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import React, { useState, useCallback, useRef } from 'react'
|
||||
import { ComplianceResultTabs } from './ComplianceResultTabs'
|
||||
import { DocumentRow } from './DocumentRow'
|
||||
import { PreScanWizard, useScanContext, isContextComplete } from './PreScanWizard'
|
||||
import { DOCUMENT_TYPES, type DocTypeId } from './_document_types'
|
||||
@@ -13,7 +12,7 @@ import {
|
||||
import { useCompanyOrigin } from './_useCompanyOrigin'
|
||||
|
||||
|
||||
export function ComplianceCheckTab() {
|
||||
export function ComplianceCheckTab({ onComplete }: { onComplete?: () => void } = {}) {
|
||||
const [docs, setDocs] = useState<DocsState>(initState)
|
||||
const { companyName, setCompanyName, originDomain, setOriginDomain } = useCompanyOrigin()
|
||||
const [scanContext, setScanContext] = useScanContext()
|
||||
@@ -243,21 +242,16 @@ export function ComplianceCheckTab() {
|
||||
}
|
||||
}
|
||||
|
||||
const loadFromHistory = (entry: HistoryEntry) => {
|
||||
if (entry.resultKey) {
|
||||
try {
|
||||
const saved = localStorage.getItem(entry.resultKey)
|
||||
if (saved) { setResults(JSON.parse(saved)); return }
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
try {
|
||||
const last = localStorage.getItem(STORAGE_KEY_RESULTS)
|
||||
if (last) setResults(JSON.parse(last))
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
const contextReady = isContextComplete(scanContext)
|
||||
|
||||
// Nach Abschluss eines Checks (loading true→false mit Ergebnis) die
|
||||
// Snapshot-Historie unten neu laden — der frische Snapshot erscheint oben.
|
||||
const prevLoading = useRef(false)
|
||||
React.useEffect(() => {
|
||||
if (prevLoading.current && !loading && results) onComplete?.()
|
||||
prevLoading.current = loading
|
||||
}, [loading, results, onComplete])
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Info box */}
|
||||
@@ -390,37 +384,12 @@ export function ComplianceCheckTab() {
|
||||
<div className="bg-red-50 border border-red-200 rounded-lg p-3 text-sm text-red-700">{error}</div>
|
||||
)}
|
||||
|
||||
{/* Results — strukturierte Themen-Tabs (Impressum, …) + Roh-Checkliste */}
|
||||
{results && results.results && (
|
||||
<ComplianceResultTabs results={results} />
|
||||
)}
|
||||
|
||||
{/* History */}
|
||||
{history.length > 0 && (
|
||||
<div className="border border-gray-200 rounded-xl p-4">
|
||||
<h4 className="text-sm font-medium text-gray-700 mb-2">Letzte Compliance-Checks</h4>
|
||||
<div className="space-y-1">
|
||||
{history.map((h, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => loadFromHistory(h)}
|
||||
className="w-full flex items-center justify-between text-sm py-2 px-2 rounded-lg border border-gray-50 hover:border-purple-200 hover:bg-purple-50/30 transition-all text-left"
|
||||
>
|
||||
<span className="text-gray-600">
|
||||
{new Date(h.date).toLocaleDateString('de-DE', {
|
||||
day: '2-digit', month: '2-digit', year: 'numeric',
|
||||
hour: '2-digit', minute: '2-digit',
|
||||
})}
|
||||
</span>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-xs text-gray-500">{h.docCount} Dok.</span>
|
||||
<span className={`text-xs font-medium ${h.findings > 0 ? 'text-amber-600' : 'text-green-600'}`}>
|
||||
{h.findings} Findings
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{/* Nach Abschluss: Hinweis auf die Historie unten. Die eigentlichen
|
||||
Ergebnisse leben in der Snapshot-Detail-Seite (oberster Eintrag). */}
|
||||
{results && results.results && !loading && (
|
||||
<div className="bg-green-50 border border-green-200 rounded-lg p-3 text-sm text-green-800">
|
||||
Check abgeschlossen — das Ergebnis steht unten in der Historie (oberster, farblich
|
||||
markierter Eintrag). Klick ihn an, um die Auswertung zu öffnen.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user