'use client' import React, { useState } from 'react' import { DSRErasureChecklist, DSRErasureChecklistItem, ERASURE_EXCEPTIONS } from '@/lib/sdk/dsr/types' interface DSRErasureChecklistProps { checklist?: DSRErasureChecklist onChange?: (checklist: DSRErasureChecklist) => void readOnly?: boolean } export function DSRErasureChecklistComponent({ checklist, onChange, readOnly = false }: DSRErasureChecklistProps) { const [localChecklist, setLocalChecklist] = useState(() => { if (checklist) return checklist return { items: ERASURE_EXCEPTIONS.map(exc => ({ ...exc, checked: false, applies: false })), canProceedWithErasure: true } }) const handleItemChange = ( itemId: string, field: 'checked' | 'applies' | 'notes', value: boolean | string ) => { const updatedItems = localChecklist.items.map(item => { if (item.id !== itemId) return item return { ...item, [field]: value } }) // Calculate if erasure can proceed (no exceptions apply) const canProceedWithErasure = !updatedItems.some(item => item.checked && item.applies) const updatedChecklist: DSRErasureChecklist = { ...localChecklist, items: updatedItems, canProceedWithErasure } setLocalChecklist(updatedChecklist) onChange?.(updatedChecklist) } const appliedExceptions = localChecklist.items.filter(item => item.checked && item.applies) const allChecked = localChecklist.items.every(item => item.checked) return (
{/* Header */}

Art. 17(3) Ausnahmen-Pruefung

Pruefen Sie, ob eine der Ausnahmen zur Loeschung zutrifft

{/* Status Badge */}
{localChecklist.canProceedWithErasure ? 'Loeschung moeglich' : `${appliedExceptions.length} Ausnahme(n)` }
{/* Info Box */}

Hinweis

Nach Art. 17(3) DSGVO bestehen Ausnahmen vom Loeschungsanspruch. Pruefen Sie jeden Punkt und dokumentieren Sie, ob eine Ausnahme greift.

{/* Checklist Items */}
{localChecklist.items.map((item, index) => ( handleItemChange(item.id, field, value)} /> ))}
{/* Summary */} {allChecked && (
{localChecklist.canProceedWithErasure ? ( ) : ( )}
{localChecklist.canProceedWithErasure ? 'Alle Ausnahmen geprueft - Loeschung kann durchgefuehrt werden' : 'Ausnahme(n) greifen - Loeschung nicht oder nur teilweise moeglich' }
{!localChecklist.canProceedWithErasure && (
    {appliedExceptions.map(exc => (
  • - {exc.article}: {exc.label}
  • ))}
)}
)} {/* Progress Indicator */} {!allChecked && (
{localChecklist.items.filter(i => i.checked).length} von {localChecklist.items.length} Ausnahmen geprueft
)}
) } // Individual Checklist Item Component function ChecklistItem({ item, index, readOnly, onChange }: { item: DSRErasureChecklistItem index: number readOnly: boolean onChange: (field: 'checked' | 'applies' | 'notes', value: boolean | string) => void }) { const [expanded, setExpanded] = useState(false) return (
{/* Main Row */}
{/* Checkbox */} {/* Content */}
{item.article} {item.label}

{item.description}

{/* Toggle Expand */}
{/* Applies Toggle - Show when checked */} {item.checked && (
Trifft diese Ausnahme zu?
)}
{/* Expanded Notes Section */} {expanded && (