'use client' import React, { useState } from 'react' import type { ScopeDecision, ComplianceDepthLevel, ApplicableRegulation, SupervisoryAuthorityInfo } from '@/lib/sdk/compliance-scope-types' import { DEPTH_LEVEL_LABELS, DEPTH_LEVEL_DESCRIPTIONS, DEPTH_LEVEL_COLORS, DOCUMENT_TYPE_LABELS } from '@/lib/sdk/compliance-scope-types' interface ScopeDecisionTabProps { decision: ScopeDecision | null answers?: unknown[] onBackToWizard?: () => void onGoToExport?: () => void canEvaluate?: boolean onEvaluate?: () => void isEvaluating?: boolean applicableRegulations?: ApplicableRegulation[] supervisoryAuthorities?: SupervisoryAuthorityInfo[] regulationAssessmentLoading?: boolean onGoToObligations?: () => void } export function ScopeDecisionTab({ decision, onBackToWizard, onGoToExport, canEvaluate, onEvaluate, isEvaluating, applicableRegulations, supervisoryAuthorities, regulationAssessmentLoading, onGoToObligations, }: ScopeDecisionTabProps) { const [expandedTrigger, setExpandedTrigger] = useState(null) const [showAuditTrail, setShowAuditTrail] = useState(false) if (!decision) { return (

Keine Entscheidung vorhanden

Bitte führen Sie zuerst das Scope-Profiling durch.

) } const getScoreColor = (score: number): string => { if (score >= 80) return 'from-red-500 to-red-600' if (score >= 60) return 'from-orange-500 to-orange-600' if (score >= 40) return 'from-yellow-500 to-yellow-600' return 'from-green-500 to-green-600' } const getSeverityBadge = (severity: string) => { const s = severity.toLowerCase() const colors: Record = { low: 'bg-gray-100 text-gray-800', medium: 'bg-yellow-100 text-yellow-800', high: 'bg-orange-100 text-orange-800', critical: 'bg-red-100 text-red-800', } const labels: Record = { low: 'Niedrig', medium: 'Mittel', high: 'Hoch', critical: 'Kritisch', } return ( {labels[s] || severity} ) } const renderScoreBar = (label: string, score: number | undefined) => { const value = score ?? 0 return (
{label} {value}/100
) } return (
{/* Level Determination */}
{decision.determinedLevel}

{DEPTH_LEVEL_LABELS[decision.determinedLevel]}

{DEPTH_LEVEL_DESCRIPTIONS[decision.determinedLevel]}

{decision.reasoning && decision.reasoning.length > 0 && (

{decision.reasoning.map(r => r.description).filter(Boolean).join('. ')}

)}
{/* Score Breakdown */} {decision.scores && (

Score-Analyse

{renderScoreBar('Risiko-Score', decision.scores.risk_score)} {renderScoreBar('Komplexitäts-Score', decision.scores.complexity_score)} {renderScoreBar('Assurance-Score', decision.scores.assurance_need)}
{renderScoreBar('Gesamt-Score', decision.scores.composite_score)}
)} {/* Applicable Regulations */} {(applicableRegulations || regulationAssessmentLoading) && (

Anwendbare Regulierungen

{regulationAssessmentLoading ? (
Regulierungen werden geprueft...
) : applicableRegulations && applicableRegulations.length > 0 ? (
{applicableRegulations.map((reg) => (
{reg.name} {reg.classification && ( {reg.classification} )}
{reg.obligation_count} Pflichten {reg.control_count > 0 && ( {reg.control_count} Controls )}
))} {/* Supervisory Authorities */} {supervisoryAuthorities && supervisoryAuthorities.length > 0 && (

Zustaendige Aufsichtsbehoerden

{supervisoryAuthorities.map((sa, idx) => (
{sa.authority.abbreviation} ({sa.domain})

{sa.authority.name}

{sa.authority.url && ( Website → )}
))}
)} {/* Link to Obligations */} {onGoToObligations && (
)}
) : (

Keine anwendbaren Regulierungen ermittelt.

)}
)} {/* Hard Triggers */} {decision.triggeredHardTriggers && decision.triggeredHardTriggers.length > 0 && (

Hard-Trigger

{decision.triggeredHardTriggers.map((trigger, idx) => (
{expandedTrigger === idx && (

{trigger.description}

{trigger.legalReference && (

Rechtsgrundlage: {trigger.legalReference}

)} {trigger.mandatoryDocuments && trigger.mandatoryDocuments.length > 0 && (

Pflichtdokumente: {trigger.mandatoryDocuments.join(', ')}

)} {trigger.requiresDSFA && (

DSFA erforderlich

)}
)}
))}
)} {/* Required Documents */} {decision.requiredDocuments && decision.requiredDocuments.length > 0 && (

Erforderliche Dokumente

{decision.requiredDocuments.map((doc, idx) => ( ))}
Dokument Priorität Aufwand Trigger Aktion
{DOCUMENT_TYPE_LABELS[doc.documentType] || doc.documentType} {doc.requirement === 'mandatory' && ( Pflicht )}
{doc.priority} {doc.estimatedEffort ? `${doc.estimatedEffort}h` : '-'} {doc.triggeredBy && doc.triggeredBy.length > 0 && ( {doc.triggeredBy.join(', ')} )} {doc.sdkStepUrl && ( Zum SDK-Schritt → )}
)} {/* Risk Flags */} {decision.riskFlags && decision.riskFlags.length > 0 && (

Risiko-Flags

{decision.riskFlags.map((flag, idx) => (

{flag.message}

{getSeverityBadge(flag.severity)}
{flag.legalReference && (

{flag.legalReference}

)}

Empfehlung: {flag.recommendation}

))}
)} {/* Gap Analysis */} {decision.gaps && decision.gaps.length > 0 && (

Gap-Analyse

{decision.gaps.map((gap, idx) => (

{gap.description}

{getSeverityBadge(gap.severity)}

Ist: {gap.currentState}

Soll: {gap.targetState}

Aufwand: ~{gap.effort}h Level: {gap.requiredFor}
))}
)} {/* Next Actions */} {decision.nextActions && decision.nextActions.length > 0 && (

Nächste Schritte

{decision.nextActions.map((action, idx) => (
{idx + 1}

{action.title}

{action.description}

{action.estimatedEffort > 0 && ( Aufwand: ~{action.estimatedEffort}h )} {action.sdkStepUrl && ( Zum SDK-Schritt → )}
))}
)} {/* Action Buttons */}
{onBackToWizard && ( )} {canEvaluate && onEvaluate && ( )} {onGoToExport && ( )}
{/* Audit Trail (from reasoning) */} {decision.reasoning && decision.reasoning.length > 0 && (
{showAuditTrail && (
{decision.reasoning.map((entry, idx) => (

{entry.step}

{entry.description}

{entry.factors && entry.factors.length > 0 && (
    {entry.factors.map((factor, factorIdx) => (
  • • {factor}
  • ))}
)} {entry.impact && (

{entry.impact}

)}
))}
)}
)}
) }