'use client' // ============================================================================= // Step 1: Scope & Roles // Company profile and role definition // ============================================================================= import React, { useState, useEffect } from 'react' import { useTOMGenerator } from '@/lib/sdk/tom-generator' import { CompanyProfile, CompanyRole, CompanySize, } from '@/lib/sdk/tom-generator/types' // ============================================================================= // CONSTANTS // ============================================================================= const COMPANY_SIZES: { value: CompanySize; label: string; description: string }[] = [ { value: 'MICRO', label: 'Kleinstunternehmen', description: '< 10 Mitarbeiter' }, { value: 'SMALL', label: 'Kleinunternehmen', description: '10-49 Mitarbeiter' }, { value: 'MEDIUM', label: 'Mittelunternehmen', description: '50-249 Mitarbeiter' }, { value: 'LARGE', label: 'Großunternehmen', description: '250-999 Mitarbeiter' }, { value: 'ENTERPRISE', label: 'Konzern', description: '1000+ Mitarbeiter' }, ] const COMPANY_ROLES: { value: CompanyRole; label: string; description: string }[] = [ { value: 'CONTROLLER', label: 'Verantwortlicher', description: 'Sie bestimmen Zweck und Mittel der Datenverarbeitung', }, { value: 'PROCESSOR', label: 'Auftragsverarbeiter', description: 'Sie verarbeiten Daten im Auftrag eines Verantwortlichen', }, { value: 'JOINT_CONTROLLER', label: 'Gemeinsam Verantwortlicher', description: 'Sie bestimmen gemeinsam mit anderen Zweck und Mittel', }, ] const INDUSTRIES = [ 'Software / IT', 'Finanzdienstleistungen', 'Gesundheitswesen', 'E-Commerce / Handel', 'Beratung / Professional Services', 'Produktion / Industrie', 'Bildung / Forschung', 'Öffentlicher Sektor', 'Medien / Kommunikation', 'Transport / Logistik', 'Sonstige', ] // ============================================================================= // COMPONENT // ============================================================================= export function ScopeRolesStep() { const { state, setCompanyProfile, completeCurrentStep } = useTOMGenerator() const [formData, setFormData] = useState>({ id: '', name: '', industry: '', size: 'MEDIUM', role: 'CONTROLLER', products: [], dpoPerson: '', dpoEmail: '', itSecurityContact: '', }) const [productInput, setProductInput] = useState('') const [errors, setErrors] = useState>({}) // Load existing data useEffect(() => { if (state.companyProfile) { setFormData(state.companyProfile) } }, [state.companyProfile]) // Validation const validate = (): boolean => { const newErrors: Record = {} if (!formData.name?.trim()) { newErrors.name = 'Unternehmensname ist erforderlich' } if (!formData.industry) { newErrors.industry = 'Bitte wählen Sie eine Branche' } if (!formData.role) { newErrors.role = 'Bitte wählen Sie eine Rolle' } if (formData.dpoEmail && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.dpoEmail)) { newErrors.dpoEmail = 'Bitte geben Sie eine gültige E-Mail-Adresse ein' } setErrors(newErrors) return Object.keys(newErrors).length === 0 } // Handle form changes const handleChange = ( e: React.ChangeEvent ) => { const { name, value } = e.target setFormData((prev) => ({ ...prev, [name]: value })) // Clear error when field is edited if (errors[name]) { setErrors((prev) => ({ ...prev, [name]: '' })) } } // Handle product addition const addProduct = () => { if (productInput.trim()) { setFormData((prev) => ({ ...prev, products: [...(prev.products || []), productInput.trim()], })) setProductInput('') } } const removeProduct = (index: number) => { setFormData((prev) => ({ ...prev, products: (prev.products || []).filter((_, i) => i !== index), })) } // Handle submit const handleSubmit = (e: React.FormEvent) => { e.preventDefault() if (!validate()) return const profile: CompanyProfile = { id: formData.id || `company-${Date.now()}`, name: formData.name!, industry: formData.industry!, size: formData.size!, role: formData.role!, products: formData.products || [], dpoPerson: formData.dpoPerson || null, dpoEmail: formData.dpoEmail || null, itSecurityContact: formData.itSecurityContact || null, } setCompanyProfile(profile) completeCurrentStep(profile) } return (
{/* Company Name */}
{errors.name &&

{errors.name}

}
{/* Industry */}
{errors.industry &&

{errors.industry}

}
{/* Company Size */}
{COMPANY_SIZES.map((size) => ( ))}
{/* Company Role */}
{COMPANY_ROLES.map((role) => ( ))}
{errors.role &&

{errors.role}

}
{/* Products/Services */}
setProductInput(e.target.value)} onKeyPress={(e) => e.key === 'Enter' && (e.preventDefault(), addProduct())} className="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="z.B. Cloud CRM, API Services" />
{formData.products && formData.products.length > 0 && (
{formData.products.map((product, index) => ( {product} ))}
)}
{/* Contact Information */}

Kontaktinformationen

{errors.dpoEmail &&

{errors.dpoEmail}

}
{/* Info Box */}

Hinweis zur Rollenwahl

Die Wahl Ihrer DSGVO-Rolle beeinflusst, welche TOMs für Sie relevant sind. Als Auftragsverarbeiter gelten zusätzliche Anforderungen nach Art. 28 DSGVO.

) } export default ScopeRolesStep