'use client' import React, { useState } from 'react' import type { ScopeDecision, ComplianceDepthLevel } 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 } export function ScopeDecisionTab({ decision }: 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.level}

{DEPTH_LEVEL_LABELS[decision.level]}

{DEPTH_LEVEL_DESCRIPTIONS[decision.level]}

{decision.reasoning && (

{decision.reasoning}

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

Score-Analyse

{renderScoreBar('Risiko-Score', decision.scores.riskScore)} {renderScoreBar('Komplexitäts-Score', decision.scores.complexityScore)} {renderScoreBar('Assurance-Score', decision.scores.assuranceScore)}
{renderScoreBar('Gesamt-Score', decision.scores.compositeScore)}
)} {/* Hard Triggers */} {decision.hardTriggers && decision.hardTriggers.length > 0 && (

Hard-Trigger

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

{trigger.description}

{trigger.legalReference && (

Rechtsgrundlage: {trigger.legalReference}

)} {trigger.matchedValue && (

Erfasster Wert: {trigger.matchedValue}

)}
)}
))}
)} {/* 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} )}
))}
)} {/* 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}
  • ))}
)}
))}
)}
)}
) }