'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: 'low' | 'medium' | 'high' | 'critical') => { const colors = { 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 = { low: 'Niedrig', medium: 'Mittel', high: 'Hoch', critical: 'Kritisch', } return ( {labels[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}

)}
{/* 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.category && (

Kategorie: {trigger.category}

)} {trigger.requiresDSFA && (

DSFA erforderlich

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

Erforderliche Dokumente

{decision.requiredDocuments.map((doc, idx) => ( ))}
Typ Tiefe Aufwand Status Aktion
{DOCUMENT_TYPE_LABELS[doc.documentType] || doc.documentType} {doc.isMandatory && ( Pflicht )}
{doc.depthDescription} {doc.effortEstimate ? `${doc.effortEstimate.days} Tage` : '-'} {doc.triggeredByHardTrigger && ( Hard-Trigger )} {doc.sdkStepUrl && ( Zum SDK-Schritt → )}
)} {/* Risk Flags */} {decision.riskFlags && decision.riskFlags.length > 0 && (

Risiko-Flags

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

{flag.title}

{getSeverityBadge(flag.severity)}

{flag.description}

Empfehlung: {flag.recommendation}

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

Gap-Analyse

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

{gap.title}

{getSeverityBadge(gap.severity)}

{gap.description}

Empfehlung: {gap.recommendation}

{gap.relatedDocuments && gap.relatedDocuments.length > 0 && (
Betroffene Dokumente: {gap.relatedDocuments.map((doc, docIdx) => ( {DOCUMENT_TYPE_LABELS[doc] || doc} ))}
)}
))}
)} {/* Next Actions */} {decision.nextActions && decision.nextActions.length > 0 && (

Nächste Schritte

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

{action.title}

{action.description}

{action.effortDays && ( Aufwand: {action.effortDays} Tage )} {action.relatedDocuments && action.relatedDocuments.length > 0 && ( Dokumente: {action.relatedDocuments.length} )}
))}
)} {/* Action Buttons */}
{onBackToWizard && ( )} {canEvaluate && onEvaluate && ( )} {onGoToExport && ( )}
{/* Audit Trail */} {decision.auditTrail && decision.auditTrail.length > 0 && (
{showAuditTrail && (
{decision.auditTrail.map((entry, idx) => (

{entry.step}

{entry.description}

{entry.details && entry.details.length > 0 && (
    {entry.details.map((detail, detailIdx) => (
  • • {detail}
  • ))}
)}
))}
)}
)}
) }