'use client'
import React from 'react'
import Link from 'next/link'
import { useSDK, SDK_PACKAGES, getStepsForPackage } from '@/lib/sdk'
import { ProjectSelector } from '@/components/sdk/ProjectSelector/ProjectSelector'
import { RegulatoryNewsFeed } from '@/components/sdk/regulatory-news/RegulatoryNewsFeed'
import { PresetSection } from './_components/PresetSection'
import type { SDKPackageId } from '@/lib/sdk/types'
// =============================================================================
// DASHBOARD CARDS
// =============================================================================
function StatCard({ title, value, subtitle, icon, color }: {
title: string; value: string | number; subtitle: string; icon: React.ReactNode; color: string
}) {
return (
{/* Header */}
AI Compliance SDK
{effectiveCustomerType === 'new' ? 'Neukunden-Modus: Erstellen Sie alle Compliance-Dokumente von Grund auf.' : 'Bestandskunden-Modus: Erweitern Sie bestehende Dokumente.'}
setCustomerType(effectiveCustomerType === 'new' ? 'existing' : 'new')} className="text-sm text-purple-600 hover:text-purple-700 underline">
{effectiveCustomerType === 'new' ? 'Zu Bestandskunden wechseln' : 'Zu Neukunden wechseln'}
{/* Industry Presets with Document Preview */}
{/* Applicable Regulations Card */}
{state.complianceScope?.decision && (
Erkannte Regulierungen
Basierend auf Ihrem Scope-Profiling (Level {state.complianceScope.decision.level})
Details & Anpassen
{(state.complianceScope.decision.requiredDocuments || []).length > 0 ? (
['DSGVO', 'AI Act', 'NIS2', 'HinSchG', 'TTDSG'].filter(reg => {
const docs = state.complianceScope?.decision?.requiredDocuments || []
const triggers = state.complianceScope?.decision?.hardTriggers || []
if (reg === 'DSGVO') return true
if (reg === 'AI Act') return triggers.some((t: string) => t.toLowerCase().includes('ai') || t.toLowerCase().includes('ki'))
if (reg === 'NIS2') return triggers.some((t: string) => t.toLowerCase().includes('nis') || t.toLowerCase().includes('kritisch'))
if (reg === 'HinSchG') return triggers.some((t: string) => t.toLowerCase().includes('whistleblower') || t.toLowerCase().includes('hinweis'))
return false
}).map(reg => (
{reg}
))
) : (
DSGVO
)}
)}
{!state.complianceScope?.decision && (
Scope-Profiling noch nicht abgeschlossen
Fuehren Sie das Scope-Profiling durch um zu erfahren welche Regulierungen fuer Ihr Unternehmen gelten.
)}
{/* Stats Grid */}
} color="bg-purple-50" />
} color="bg-blue-50" />
} color="bg-green-50" />
0 ? `${criticalRisks} kritisch` : 'Keine kritischen'}
icon={ } color="bg-orange-50" />
{/* Bestandskunden: Gap Analysis Banner */}
{effectiveCustomerType === 'existing' && state.importedDocuments.length === 0 && (
📄
Bestehende Dokumente importieren
Laden Sie Ihre vorhandenen Compliance-Dokumente hoch. Unsere KI analysiert sie und zeigt Ihnen, welche Erweiterungen erforderlich sind.
Dokumente hochladen
)}
{/* Gap Analysis Results */}
{state.gapAnalysis && (
📊
Gap-Analyse Ergebnis
{state.gapAnalysis.totalGaps} Luecken gefunden
{state.gapAnalysis.criticalGaps}
Kritisch
{state.gapAnalysis.highGaps}
Hoch
{state.gapAnalysis.mediumGaps}
Mittel
{state.gapAnalysis.lowGaps}
Niedrig
)}
{/* 5 Packages */}
Compliance-Pakete
{SDK_PACKAGES.map(pkg => {
const steps = getStepsForPackage(pkg.id)
const visibleSteps = steps.filter(s => !(s.id === 'import' && effectiveCustomerType === 'new'))
return
})}
{/* Quick Actions */}
Schnellaktionen
}
href="/sdk/advisory-board" color="bg-purple-50" projectId={projectId} />
}
href="/sdk/screening" color="bg-red-50" projectId={projectId} />
}
href="/sdk/dsfa" color="bg-blue-50" projectId={projectId} />
}
href="/sdk/rag" color="bg-green-50" projectId={projectId} />
{/* Compliance Report Download */}
Compliance-Report
Umfassender PDF-Bericht ueber alle Module, Rollen, Risiken und Massnahmen.
{
const url = `/api/sdk/v1/compliance/report/pdf${projectId ? `?project_id=${projectId}` : ''}`
window.open(url, '_blank')
}}
className="px-5 py-2.5 bg-purple-600 text-white text-sm font-medium rounded-lg hover:bg-purple-700 transition-colors flex items-center gap-2"
>
PDF herunterladen
{/* Recent Activity */}
{state.commandBarHistory.length > 0 && (
Letzte Aktivitaeten
{state.commandBarHistory.slice(0, 5).map(entry => (
{entry.query}
{new Date(entry.timestamp).toLocaleString('de-DE')}
{entry.type}
))}
)}
)
}