'use client'
import React from 'react'
import { Art22Assessment, Art22ExceptionType } from '@/lib/sdk/dsfa/ai-use-case-types'
interface Art22AssessmentPanelProps {
assessment: Art22Assessment
onChange: (updated: Art22Assessment) => void
readonly?: boolean
}
const EXCEPTION_OPTIONS: { value: Art22ExceptionType; label: string; description: string }[] = [
{
value: 'contract',
label: 'Art. 22 Abs. 2 lit. a – Vertragserfüllung',
description: 'Die Entscheidung ist für den Abschluss oder die Erfüllung eines Vertrags erforderlich',
},
{
value: 'legal',
label: 'Art. 22 Abs. 2 lit. b – Rechtliche Verpflichtung',
description: 'Die Entscheidung ist durch Unionsrecht oder mitgliedstaatliches Recht zugelassen',
},
{
value: 'consent',
label: 'Art. 22 Abs. 2 lit. c – Ausdrückliche Einwilligung',
description: 'Die betroffene Person hat ausdrücklich eingewilligt',
},
]
export function Art22AssessmentPanel({ assessment, onChange, readonly }: Art22AssessmentPanelProps) {
const missingRequiredSafeguards = assessment.applies &&
!assessment.safeguards.some(s => s.id === 'human_review' && s.implemented)
return (
{/* Art. 22 Toggle */}
onChange({ ...assessment, applies: e.target.checked })}
disabled={readonly}
className="mt-1 h-4 w-4 rounded border-gray-300 text-purple-600 focus:ring-purple-500"
/>
{/* Warning if applies without safeguards */}
{missingRequiredSafeguards && (
Art. 22 gilt als anwendbar, aber die erforderliche Schutzmaßnahme „Recht auf menschliche Überprüfung" ist nicht implementiert.
)}
{assessment.applies && (
<>
{/* Justification */}
{/* Exception Type */}
{EXCEPTION_OPTIONS.map(opt => (
))}
{/* Safeguards */}
{assessment.safeguards.map((safeguard, idx) => (
))}
>
)}
)
}