'use client' import React, { useState } from 'react' import { DSRDataExport, DSRType } from '@/lib/sdk/dsr/types' interface DSRDataExportProps { dsrId: string dsrType: DSRType // 'access' or 'portability' existingExport?: DSRDataExport onGenerate?: (format: 'json' | 'csv' | 'xml' | 'pdf') => Promise onDownload?: () => Promise isGenerating?: boolean } const FORMAT_OPTIONS: { value: 'json' | 'csv' | 'xml' | 'pdf' label: string description: string icon: string recommended?: boolean }[] = [ { value: 'json', label: 'JSON', description: 'Maschinenlesbar, ideal fuer technische Uebertragung', icon: 'M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4', recommended: true }, { value: 'csv', label: 'CSV', description: 'Tabellen-Format, mit Excel oeffenbar', icon: 'M3 10h18M3 14h18m-9-4v8m-7 0h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z' }, { value: 'xml', label: 'XML', description: 'Strukturiertes Format fuer System-Integration', icon: 'M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4' }, { value: 'pdf', label: 'PDF', description: 'Menschenlesbar, ideal fuer direkte Zusendung', icon: 'M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z' } ] function formatFileSize(bytes: number): string { if (bytes < 1024) return `${bytes} B` if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB` return `${(bytes / (1024 * 1024)).toFixed(1)} MB` } function formatDate(dateString: string): string { return new Date(dateString).toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' }) } export function DSRDataExportComponent({ dsrId, dsrType, existingExport, onGenerate, onDownload, isGenerating = false }: DSRDataExportProps) { const [selectedFormat, setSelectedFormat] = useState<'json' | 'csv' | 'xml' | 'pdf'>( dsrType === 'portability' ? 'json' : 'pdf' ) const [includeThirdParty, setIncludeThirdParty] = useState(true) const [transferRecipient, setTransferRecipient] = useState('') const [showTransferSection, setShowTransferSection] = useState(false) const isPortability = dsrType === 'portability' const handleGenerate = async () => { if (onGenerate) { await onGenerate(selectedFormat) } } return (
{/* Header */}

{isPortability ? 'Datenexport (Art. 20)' : 'Datenauskunft (Art. 15)'}

{isPortability ? 'Exportieren Sie die Daten in einem maschinenlesbaren Format zur Uebertragung' : 'Erstellen Sie eine Uebersicht aller gespeicherten personenbezogenen Daten' }

{/* Existing Export */} {existingExport && existingExport.generatedAt && (
Export vorhanden
Format: {existingExport.format.toUpperCase()}
Erstellt: {formatDate(existingExport.generatedAt)}
{existingExport.fileName && (
Datei: {existingExport.fileName}
)} {existingExport.fileSize && (
Groesse: {formatFileSize(existingExport.fileSize)}
)}
{onDownload && ( )}
)} {/* Format Selection */}
{FORMAT_OPTIONS.map(format => ( ))}
{/* Options */}
{/* Include Third-Party Data */} {/* Data Transfer (Art. 20 only) */} {isPortability && (
{showTransferSection && (
setTransferRecipient(e.target.value)} placeholder="Name des Unternehmens oder E-Mail-Adresse" className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500" />

Die Daten werden an den angegebenen Empfaenger uebermittelt, sofern dies technisch machbar ist.

)}
)}
{/* Info Box */}

Enthaltene Datenkategorien

  • Stammdaten (Name, E-Mail, Adresse)
  • Nutzungsdaten (Login-Historie, Aktivitaeten)
  • Kommunikationsdaten (E-Mails, Support-Anfragen)
  • {includeThirdParty &&
  • Tracking-Daten (Analytics, Cookies)
  • }
{/* Generate Button */} {onGenerate && (
)}
) }