'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 (
{title}
{value}
{subtitle}
{icon}
)
}
function PackageCard({ pkg, completion, stepsCount, isLocked, projectId }: {
pkg: (typeof SDK_PACKAGES)[number]; completion: number; stepsCount: number; isLocked: boolean; projectId?: string
}) {
const steps = getStepsForPackage(pkg.id)
const firstStep = steps[0]
const baseHref = firstStep?.url || '/sdk'
const href = projectId ? `${baseHref}?project=${projectId}` : baseHref
const content = (
{isLocked ? (
) : completion === 100 ? (
) : pkg.icon}
{pkg.order}.
{pkg.name}
{pkg.description}
{stepsCount} Schritte
{completion}%
{!isLocked &&
Ergebnis: {pkg.result}
}
)
return isLocked ? content : {content}
}
function QuickActionCard({ title, description, icon, href, color, projectId }: {
title: string; description: string; icon: React.ReactNode; href: string; color: string; projectId?: string
}) {
const finalHref = projectId ? `${href}?project=${projectId}` : href
return (
{icon}
)
}
// =============================================================================
// MAIN DASHBOARD
// =============================================================================
export default function SDKDashboard() {
const { state, packageCompletion, completionPercentage, setCustomerType, projectId } = useSDK()
const effectiveCustomerType = state.customerType || 'new'
if (!projectId) return
const totalSteps = SDK_PACKAGES.reduce((sum, pkg) => {
const steps = getStepsForPackage(pkg.id)
return sum + steps.filter(s => !(s.id === 'import' && effectiveCustomerType === 'new')).length
}, 0)
const completedCheckpoints = Object.values(state.checkpoints).filter(cp => cp.passed).length
const totalRisks = state.risks.length
const criticalRisks = state.risks.filter(r => r.severity === 'CRITICAL' || r.severity === 'HIGH').length
const isPackageLocked = (packageId: SDKPackageId): boolean => {
if (state.preferences?.allowParallelWork) return false
const pkg = SDK_PACKAGES.find(p => p.id === packageId)
if (!pkg || pkg.order === 1) return false
const prevPkg = SDK_PACKAGES.find(p => p.order === pkg.order - 1)
if (!prevPkg) return false
return packageCompletion[prevPkg.id] < 100
}
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 */}
{/* 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}
))}
)}
)
}