'use client'
import React from 'react'
import { LoeschfristPolicy } from '@/lib/sdk/loeschfristen-types'
import { ComplianceCheckResult } from '@/lib/sdk/loeschfristen-compliance'
import {
exportPoliciesAsJSON, exportPoliciesAsCSV,
generateComplianceSummary, downloadFile,
} from '@/lib/sdk/loeschfristen-export'
// ---------------------------------------------------------------------------
// Types
// ---------------------------------------------------------------------------
interface ExportTabProps {
policies: LoeschfristPolicy[]
complianceResult: ComplianceCheckResult | null
runCompliance: () => void
setEditingId: (id: string | null) => void
setTab: (tab: 'uebersicht' | 'editor' | 'generator' | 'export') => void
}
// ---------------------------------------------------------------------------
// Component
// ---------------------------------------------------------------------------
export function ExportTab({
policies,
complianceResult,
runCompliance,
setEditingId,
setTab,
}: ExportTabProps) {
const allLegalHolds = policies.flatMap((p) =>
p.legalHolds.map((h) => ({
...h,
policyId: p.policyId,
policyName: p.dataObjectName,
})),
)
const activeLegalHolds = allLegalHolds.filter((h) => h.status === 'ACTIVE')
return (
{/* Compliance Check */}
Compliance-Check
{policies.length === 0 && (
Erstellen Sie zuerst Loeschfristen, um eine Compliance-Analyse durchzufuehren.
)}
{complianceResult && (
)}
{/* Legal Hold Management */}
Legal Hold Verwaltung
{allLegalHolds.length === 0 ? (
Keine Legal Holds vorhanden.
) : (
Gesamt:{' '}
{allLegalHolds.length}
Aktiv:{' '}
{activeLegalHolds.length}
| Loeschfrist |
Bezeichnung |
Grund |
Status |
Erstellt |
{allLegalHolds.map((hold, idx) => (
|
|
{hold.name || '-'} |
{hold.reason || '-'} |
{hold.status === 'ACTIVE' ? 'Aktiv' : hold.status === 'RELEASED' ? 'Aufgehoben' : 'Abgelaufen'}
|
{hold.createdAt || '-'} |
))}
)}
{/* Export */}
Datenexport
Exportieren Sie Ihre Loeschfristen und den Compliance-Status in verschiedenen Formaten.
{policies.length === 0 ? (
Erstellen Sie zuerst Loeschfristen, um Exporte zu generieren.
) : (
)}
)
}
// ---------------------------------------------------------------------------
// Compliance result sub-component
// ---------------------------------------------------------------------------
function ComplianceResultView({
complianceResult,
setEditingId,
setTab,
}: {
complianceResult: ComplianceCheckResult
setEditingId: (id: string | null) => void
setTab: (tab: 'uebersicht' | 'editor' | 'generator' | 'export') => void
}) {
return (
{/* Score */}
= 75 ? 'text-green-600'
: complianceResult.score >= 50 ? 'text-yellow-600' : 'text-red-600'
}`}>
{complianceResult.score}
Compliance-Score
{complianceResult.score >= 75 ? 'Guter Zustand - wenige Optimierungen noetig'
: complianceResult.score >= 50 ? 'Verbesserungsbedarf - wichtige Punkte offen'
: 'Kritisch - dringender Handlungsbedarf'}
{/* Issues grouped by severity */}
{(['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'] as const).map((severity) => {
const issues = complianceResult.issues.filter((i) => i.severity === severity)
if (issues.length === 0) return null
const severityConfig = {
CRITICAL: { label: 'Kritisch', bg: 'bg-red-50', border: 'border-red-200', text: 'text-red-800', badge: 'bg-red-100 text-red-800' },
HIGH: { label: 'Hoch', bg: 'bg-orange-50', border: 'border-orange-200', text: 'text-orange-800', badge: 'bg-orange-100 text-orange-800' },
MEDIUM: { label: 'Mittel', bg: 'bg-yellow-50', border: 'border-yellow-200', text: 'text-yellow-800', badge: 'bg-yellow-100 text-yellow-800' },
LOW: { label: 'Niedrig', bg: 'bg-blue-50', border: 'border-blue-200', text: 'text-blue-800', badge: 'bg-blue-100 text-blue-800' },
}[severity]
return (
{severityConfig.label}
{issues.length} {issues.length === 1 ? 'Problem' : 'Probleme'}
{issues.map((issue, idx) => (
{issue.title}
{issue.description}
{issue.recommendation && (
Empfehlung: {issue.recommendation}
)}
{issue.affectedPolicyId && (
)}
))}
)
})}
{complianceResult.issues.length === 0 && (
Keine Compliance-Probleme gefunden
Alle Loeschfristen entsprechen den Anforderungen.
)}
)
}