'use client' import React, { useState } from 'react' import { useAgentAnalysis } from './_hooks/useAgentAnalysis' import { AnalysisResult } from './_components/AnalysisResult' import { AnalysisHistory } from './_components/AnalysisHistory' import { FollowUpQuestions } from './_components/FollowUpQuestions' import { ScanResult } from './_components/ScanResult' type AnalysisMode = 'pre_launch' | 'post_launch' type AnalysisTab = 'quick' | 'scan' const MODES: { id: AnalysisMode; label: string; desc: string; icon: string }[] = [ { id: 'pre_launch', label: 'Internes Dokument', desc: 'Vor Veroeffentlichung pruefen', icon: '📋' }, { id: 'post_launch', label: 'Live-Website', desc: 'Bereits online analysieren', icon: '🌐' }, ] const TABS: { id: AnalysisTab; label: string; desc: string }[] = [ { id: 'quick', label: 'Schnellanalyse', desc: 'Einzelne Seite klassifizieren + bewerten' }, { id: 'scan', label: 'Website-Scan', desc: 'Mehrere Seiten scannen + Dienstleister abgleichen' }, ] export default function AgentPage() { const [url, setUrl] = useState('') const [mode, setMode] = useState('post_launch') const [tab, setTab] = useState('quick') const [scanLoading, setScanLoading] = useState(false) const [scanError, setScanError] = useState(null) const [scanData, setScanData] = useState(null) const { analyze, answerFollowUp, loading, error, result, history } = useAgentAnalysis() const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (!url.trim()) return if (tab === 'quick') { analyze(url.trim(), mode) } else { setScanLoading(true) setScanError(null) setScanData(null) try { const res = await fetch('/api/sdk/v1/agent/scan', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ url: url.trim(), mode }), }) if (!res.ok) throw new Error(`Scan fehlgeschlagen: ${res.status}`) setScanData(await res.json()) } catch (e) { setScanError(e instanceof Error ? e.message : 'Unbekannter Fehler') } finally { setScanLoading(false) } } } const isLoading = tab === 'quick' ? loading : scanLoading const currentError = tab === 'quick' ? error : scanError return (

Compliance Agent

Analysiere Dokumente und Webseiten auf DSGVO-Konformitaet.

{/* Mode Selection */}
{MODES.map(m => ( ))}
{/* Tab Selection */}
{TABS.map(t => ( ))}
{/* URL Input */}
setUrl(e.target.value)} placeholder={tab === 'scan' ? 'https://www.example.com/' : 'https://example.com/datenschutz'} className="flex-1 px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent text-sm" disabled={isLoading} required />
{/* Error */} {currentError && (
{currentError}
)} {/* Quick Analysis Result */} {tab === 'quick' && result && (
{result.follow_up_questions.length > 0 && (
)}
)} {/* Scan Result */} {tab === 'scan' && scanData && (
)} {/* History (quick only) */} {tab === 'quick' && ( { setUrl(r.url); analyze(r.url, mode) }} /> )}
) }