'use client' import React, { useState, useEffect } from 'react' import { useParams } from 'next/navigation' interface Classification { id: string regulation: string regulation_label: string classification_result: string risk_level: string confidence: number reasoning: string classified_at: string | null } const REGULATIONS = [ { key: 'ai_act', label: 'AI Act', description: 'EU-Verordnung ueber kuenstliche Intelligenz (2024/1689)', icon: '🤖', }, { key: 'machinery_regulation', label: 'Maschinenverordnung', description: 'EU-Maschinenverordnung (2023/1230)', icon: '⚙️', }, { key: 'cra', label: 'Cyber Resilience Act', description: 'EU-Verordnung ueber Cyberresilienz', icon: '🔒', }, { key: 'nis2', label: 'NIS2', description: 'Richtlinie ueber Netz- und Informationssicherheit', icon: '🌐', }, ] function RiskLevelBadge({ level }: { level: string }) { const colors: Record = { unacceptable: 'bg-black text-white', high: 'bg-red-100 text-red-700', limited: 'bg-yellow-100 text-yellow-700', minimal: 'bg-green-100 text-green-700', not_applicable: 'bg-gray-100 text-gray-500', critical: 'bg-red-100 text-red-700', important: 'bg-orange-100 text-orange-700', default_category: 'bg-blue-100 text-blue-700', essential: 'bg-orange-100 text-orange-700', non_essential: 'bg-green-100 text-green-700', } const labels: Record = { unacceptable: 'Unakzeptabel', high: 'Hochrisiko', limited: 'Begrenztes Risiko', minimal: 'Minimales Risiko', not_applicable: 'Nicht anwendbar', critical: 'Kritisch', important: 'Wichtig', default_category: 'Standard', essential: 'Wesentlich', non_essential: 'Nicht wesentlich', } return ( {labels[level] || level} ) } function ConfidenceBar({ value }: { value: number }) { const pct = Math.round(value * 100) const color = pct >= 80 ? 'bg-green-500' : pct >= 60 ? 'bg-yellow-500' : 'bg-orange-500' return (
{pct}%
) } function ClassificationCard({ regulation, classification, onReclassify, classifying, }: { regulation: (typeof REGULATIONS)[number] classification: Classification | null onReclassify: (regKey: string) => void classifying: boolean }) { return (
{regulation.icon}

{regulation.label}

{regulation.description}

{classification ? (
Ergebnis {classification.classification_result}
Risikostufe
Konfidenz
Begruendung

{classification.reasoning}

{classification.classified_at && (
Klassifiziert am: {new Date(classification.classified_at).toLocaleDateString('de-DE')}
)}
) : (

Noch nicht klassifiziert

Klicken Sie "Klassifizieren" um die Analyse zu starten

)}
) } export default function ClassificationPage() { const params = useParams() const projectId = params.projectId as string const [classifications, setClassifications] = useState([]) const [loading, setLoading] = useState(true) const [classifyingAll, setClassifyingAll] = useState(false) const [classifyingReg, setClassifyingReg] = useState(null) useEffect(() => { fetchClassifications() }, [projectId]) async function fetchClassifications() { try { const res = await fetch(`/api/sdk/v1/iace/projects/${projectId}/classifications`) if (res.ok) { const json = await res.json() setClassifications(json.classifications || json || []) } } catch (err) { console.error('Failed to fetch classifications:', err) } finally { setLoading(false) } } async function handleClassifyAll() { setClassifyingAll(true) try { const res = await fetch(`/api/sdk/v1/iace/projects/${projectId}/classifications/classify-all`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, }) if (res.ok) { await fetchClassifications() } } catch (err) { console.error('Failed to classify all:', err) } finally { setClassifyingAll(false) } } async function handleReclassify(regKey: string) { setClassifyingReg(regKey) try { const res = await fetch(`/api/sdk/v1/iace/projects/${projectId}/classifications/${regKey}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, }) if (res.ok) { await fetchClassifications() } } catch (err) { console.error('Failed to reclassify:', err) } finally { setClassifyingReg(null) } } function getClassificationForReg(regKey: string): Classification | null { return classifications.find((c) => c.regulation === regKey) || null } if (loading) { return (
) } return (
{/* Header */}

Regulatorische Klassifikation

Automatische Einordnung Ihrer Maschine/Anlage in die relevanten EU-Regulierungsrahmen.

{/* Classification Cards */}
{REGULATIONS.map((reg) => ( ))}
) }