'use client' import React, { useState, useEffect } from 'react' import { useSDK } from '@/lib/sdk' import { CompanyProfile, BusinessModel, OfferingType, TargetMarket, CompanySize, LegalForm, MachineBuilderProfile, MachineProductType, AIIntegrationType, HumanOversightLevel, CriticalSector, BUSINESS_MODEL_LABELS, OFFERING_TYPE_LABELS, TARGET_MARKET_LABELS, COMPANY_SIZE_LABELS, MACHINE_PRODUCT_TYPE_LABELS, AI_INTEGRATION_TYPE_LABELS, HUMAN_OVERSIGHT_LABELS, CRITICAL_SECTOR_LABELS, } from '@/lib/sdk/types' // ============================================================================= // WIZARD STEPS // ============================================================================= const BASE_WIZARD_STEPS = [ { id: 1, name: 'Basisinfos', description: 'Firmenname und Rechtsform' }, { id: 2, name: 'Geschaeftsmodell', description: 'B2B, B2C und Angebote' }, { id: 3, name: 'Firmengroesse', description: 'Mitarbeiter und Umsatz' }, { id: 4, name: 'Standorte', description: 'Hauptsitz und Zielmaerkte' }, { id: 5, name: 'Datenschutz', description: 'Rollen und KI-Nutzung' }, { id: 6, name: 'Systeme & KI', description: 'IT-Systeme und KI-Katalog' }, { id: 7, name: 'Rechtlicher Rahmen', description: 'Regulierungen und Prüfzyklen' }, ] const MACHINE_BUILDER_STEP = { id: 8, name: 'Produkt & Maschine', description: 'Software, KI und CE in Ihrem Produkt' } function getWizardSteps(industry: string) { if (isMachineBuilderIndustry(industry)) { return [...BASE_WIZARD_STEPS, MACHINE_BUILDER_STEP] } return BASE_WIZARD_STEPS } // Keep WIZARD_STEPS for backwards compat in static references const WIZARD_STEPS = BASE_WIZARD_STEPS // ============================================================================= // LEGAL FORMS // ============================================================================= const LEGAL_FORM_LABELS: Record = { einzelunternehmen: 'Einzelunternehmen', gbr: 'GbR', ohg: 'OHG', kg: 'KG', gmbh: 'GmbH', ug: 'UG (haftungsbeschränkt)', ag: 'AG', gmbh_co_kg: 'GmbH & Co. KG', ev: 'e.V. (Verein)', stiftung: 'Stiftung', other: 'Sonstige', } // ============================================================================= // INDUSTRIES // ============================================================================= const INDUSTRIES = [ 'Technologie / IT', 'E-Commerce / Handel', 'Finanzdienstleistungen', 'Gesundheitswesen', 'Bildung', 'Beratung / Consulting', 'Marketing / Agentur', 'Produktion / Industrie', 'Logistik / Transport', 'Immobilien', 'Maschinenbau', 'Anlagenbau', 'Automatisierung', 'Robotik', 'Messtechnik', 'Sonstige', ] const MACHINE_BUILDER_INDUSTRIES = [ 'Maschinenbau', 'Anlagenbau', 'Automatisierung', 'Robotik', 'Messtechnik', ] const isMachineBuilderIndustry = (industry: string) => MACHINE_BUILDER_INDUSTRIES.includes(industry) // ============================================================================= // STEP COMPONENTS // ============================================================================= function StepBasicInfo({ data, onChange, }: { data: Partial onChange: (updates: Partial) => void }) { return (
onChange({ companyName: e.target.value })} placeholder="Ihre Firma (ohne Rechtsform)" className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
{ const val = parseInt(e.target.value) onChange({ foundedYear: isNaN(val) ? null : val }) }} onFocus={e => { if (!data.foundedYear) onChange({ foundedYear: 2000 }) }} placeholder="2020" min="1900" max={new Date().getFullYear()} className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
) } // URL fields shown when specific offerings are selected const OFFERING_URL_CONFIG: Partial> = { website: { label: 'Website-Domain', placeholder: 'https://www.beispiel.de', hint: 'Ihre Unternehmenswebsite' }, webshop: { label: 'Online-Shop URL', placeholder: 'https://shop.beispiel.de', hint: 'URL zu Ihrem Online-Shop' }, app_mobile: { label: 'App-Store Links', placeholder: 'https://apps.apple.com/... oder https://play.google.com/...', hint: 'Apple App Store und/oder Google Play Store Link' }, software_saas: { label: 'SaaS-Portal URL', placeholder: 'https://app.beispiel.de', hint: 'Login-/Registrierungsseite Ihres Kundenportals' }, app_web: { label: 'Web-App URL', placeholder: 'https://app.beispiel.de', hint: 'URL zu Ihrer Web-Anwendung' }, } // Step-specific explanations for "Warum diese Fragen?" const STEP_EXPLANATIONS: Record = { 1: 'Rechtsform und Gründungsjahr bestimmen, welche Meldepflichten und Schwellenwerte für Ihr Unternehmen gelten (z.B. NIS2, AI Act).', 2: 'Ihr Geschäftsmodell und Ihre Angebote bestimmen, welche DSGVO-Pflichten greifen: B2C erfordert z.B. strengere Einwilligungsregeln, Webshops brauchen Cookie-Banner und Datenschutzerklärungen, SaaS-Angebote eine Auftragsverarbeitung.', 3: 'Die Unternehmensgröße bestimmt, ob Sie einen DSB benennen müssen (ab 20 MA), ob NIS2-Pflichten greifen und welche Audit-Anforderungen gelten.', 4: 'Standorte und Zielmärkte bestimmen, welche nationalen Datenschutzgesetze zusätzlich zur DSGVO greifen (z.B. BDSG, DSG-AT, UK GDPR, CCPA).', 5: 'Ob Sie Verantwortlicher oder Auftragsverarbeiter sind, bestimmt Ihre DSGVO-Pflichten grundlegend. KI-Nutzung löst zusätzliche AI-Act-Pflichten aus.', 6: 'Ihre IT-Systeme und KI-Anwendungen werden für das Verarbeitungsverzeichnis (VVT), die technisch-organisatorischen Maßnahmen (TOM) und die KI-Risikobewertung benötigt.', 7: 'Regulierungsrahmen und Prüfzyklen definieren, welche Compliance-Module für Sie aktiviert werden und in welchem Rhythmus Audits stattfinden.', 8: 'Als Maschinenbauer gelten zusätzliche Anforderungen: CE-Kennzeichnung, Maschinenverordnung, Produktsicherheit und ggf. Hochrisiko-KI im Sinne des AI Act.', } function StepBusinessModel({ data, onChange, }: { data: Partial onChange: (updates: Partial) => void }) { const toggleOffering = (offering: OfferingType) => { const current = data.offerings || [] if (current.includes(offering)) { // Remove offering and its URL const urls = { ...(data.offeringUrls || {}) } delete urls[offering] onChange({ offerings: current.filter(o => o !== offering), offeringUrls: urls }) } else { onChange({ offerings: [...current, offering] }) } } const updateOfferingUrl = (offering: string, url: string) => { onChange({ offeringUrls: { ...(data.offeringUrls || {}), [offering]: url } }) } // Offerings that are selected and have URL config const selectedWithUrls = (data.offerings || []).filter(o => o in OFFERING_URL_CONFIG) return (
{Object.entries(BUSINESS_MODEL_LABELS).map(([value, label]) => ( ))}
{Object.entries(OFFERING_TYPE_LABELS).map(([value, { label, description }]) => ( ))}
{/* URL fields for selected offerings */} {selectedWithUrls.length > 0 && (
{selectedWithUrls.map(offering => { const config = OFFERING_URL_CONFIG[offering]! return (
updateOfferingUrl(offering, e.target.value)} placeholder={config.placeholder} className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" />

{config.hint}

) })}
)}
) } function StepCompanySize({ data, onChange, }: { data: Partial onChange: (updates: Partial) => void }) { return (
{Object.entries(COMPANY_SIZE_LABELS).map(([value, label]) => ( ))}
) } function StepLocations({ data, onChange, }: { data: Partial onChange: (updates: Partial) => void }) { const toggleMarket = (market: TargetMarket) => { const current = data.targetMarkets || [] if (current.includes(market)) { onChange({ targetMarkets: current.filter(m => m !== market) }) } else { onChange({ targetMarkets: [...current, market] }) } } return (
onChange({ headquartersCity: e.target.value })} placeholder="z.B. Berlin" className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
{Object.entries(TARGET_MARKET_LABELS).map(([value, { label, description, regulations }]) => ( ))}
) } function StepDataProtection({ data, onChange, }: { data: Partial onChange: (updates: Partial) => void }) { return (
onChange({ dpoName: e.target.value || null })} placeholder="Optional" className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
onChange({ dpoEmail: e.target.value || null })} placeholder="dsb@firma.de" className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
) } // ============================================================================= // STEP 6: SYSTEME & KI // ============================================================================= interface ProcessingSystem { name: string vendor: string hosting: string personal_data_categories: string[] } interface AISystem { name: string purpose: string risk_category: string vendor: string has_human_oversight: boolean } function StepSystemsAndAI({ data, onChange, }: { data: Partial & { processingSystems?: ProcessingSystem[]; aiSystems?: AISystem[] } onChange: (updates: Record) => void }) { const systems = (data as any).processingSystems || [] const aiSystems = (data as any).aiSystems || [] const addSystem = () => { onChange({ processingSystems: [...systems, { name: '', vendor: '', hosting: 'cloud', personal_data_categories: [] }] }) } const removeSystem = (i: number) => { onChange({ processingSystems: systems.filter((_: ProcessingSystem, idx: number) => idx !== i) }) } const updateSystem = (i: number, updates: Partial) => { const updated = [...systems] updated[i] = { ...updated[i], ...updates } onChange({ processingSystems: updated }) } const addAISystem = () => { onChange({ aiSystems: [...aiSystems, { name: '', purpose: '', risk_category: 'limited', vendor: '', has_human_oversight: true }] }) } const removeAISystem = (i: number) => { onChange({ aiSystems: aiSystems.filter((_: AISystem, idx: number) => idx !== i) }) } const updateAISystem = (i: number, updates: Partial) => { const updated = [...aiSystems] updated[i] = { ...updated[i], ...updates } onChange({ aiSystems: updated }) } return (
{/* Processing Systems */}

IT-Systeme mit personenbezogenen Daten

Systeme, die personenbezogene Daten verarbeiten (fuer VVT-Generierung)

{systems.length === 0 && (
Noch keine Systeme hinzugefuegt
)}
{systems.map((sys: ProcessingSystem, i: number) => (
System {i + 1}
updateSystem(i, { name: e.target.value })} placeholder="Name (z.B. SAP HR)" className="px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" /> updateSystem(i, { vendor: e.target.value })} placeholder="Hersteller" className="px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
updateSystem(i, { personal_data_categories: e.target.value.split(',').map(s => s.trim()).filter(Boolean) })} placeholder="Datenkategorien (kommagetrennt)" className="px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
))}
{/* AI Systems */}

KI-Systeme

Strukturierter KI-Katalog fuer AI Act Compliance

{aiSystems.length === 0 && (
Noch keine KI-Systeme
)}
{aiSystems.map((ai: AISystem, i: number) => (
KI-System {i + 1}
updateAISystem(i, { name: e.target.value })} placeholder="Name (z.B. Chatbot)" className="px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" /> updateAISystem(i, { vendor: e.target.value })} placeholder="Anbieter" className="px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
updateAISystem(i, { purpose: e.target.value })} placeholder="Zweck (z.B. Kundensupport)" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
))}
) } // ============================================================================= // STEP 7: RECHTLICHER RAHMEN // ============================================================================= function StepLegalFramework({ data, onChange, }: { data: Partial & { subjectToNis2?: boolean; subjectToAiAct?: boolean; subjectToIso27001?: boolean; supervisoryAuthority?: string; reviewCycleMonths?: number; technicalContacts?: { name: string; role: string; email: string }[] } onChange: (updates: Record) => void }) { const contacts = (data as any).technicalContacts || [] const addContact = () => { onChange({ technicalContacts: [...contacts, { name: '', role: '', email: '' }] }) } const removeContact = (i: number) => { onChange({ technicalContacts: contacts.filter((_: { name: string; role: string; email: string }, idx: number) => idx !== i) }) } const updateContact = (i: number, updates: Partial<{ name: string; role: string; email: string }>) => { const updated = [...contacts] updated[i] = { ...updated[i], ...updates } onChange({ technicalContacts: updated }) } return (
{/* Regulatory Flags */}

Regulatorischer Rahmen

{[ { key: 'subjectToNis2', label: 'NIS2-Richtlinie', desc: 'Ihr Unternehmen fällt unter die NIS2-Richtlinie (Netzwerk- und Informationssicherheit)' }, { key: 'subjectToAiAct', label: 'EU AI Act', desc: 'Ihr Unternehmen setzt KI-Systeme ein, die unter den AI Act fallen' }, { key: 'subjectToIso27001', label: 'ISO 27001', desc: 'Ihr Unternehmen strebt ISO 27001 Zertifizierung an oder ist bereits zertifiziert' }, ].map(item => ( ))}
{/* Supervisory Authority & Review Cycle */}
{/* Technical Contacts */}

Technische Ansprechpartner

CISO, IT-Manager, DSB etc.

{contacts.length === 0 && (
Noch keine Kontakte
)}
{contacts.map((c: { name: string; role: string; email: string }, i: number) => (
updateContact(i, { name: e.target.value })} placeholder="Name" className="flex-1 px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" /> updateContact(i, { role: e.target.value })} placeholder="Rolle (z.B. CISO)" className="flex-1 px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" /> updateContact(i, { email: e.target.value })} placeholder="E-Mail" className="flex-1 px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" />
))}
) } // ============================================================================= // STEP 8: PRODUKT & MASCHINE (nur fuer Maschinenbauer) // ============================================================================= const EMPTY_MACHINE_BUILDER: MachineBuilderProfile = { productTypes: [], productDescription: '', productPride: '', containsSoftware: false, containsFirmware: false, containsAI: false, aiIntegrationType: [], hasSafetyFunction: false, safetyFunctionDescription: '', autonomousBehavior: false, humanOversightLevel: 'full', isNetworked: false, hasRemoteAccess: false, hasOTAUpdates: false, updateMechanism: '', exportMarkets: [], criticalSectorClients: false, criticalSectors: [], oemClients: false, ceMarkingRequired: false, existingCEProcess: false, hasRiskAssessment: false, } function StepMachineBuilder({ data, onChange, }: { data: Partial onChange: (updates: Partial) => void }) { const mb = data.machineBuilder || EMPTY_MACHINE_BUILDER const updateMB = (updates: Partial) => { onChange({ machineBuilder: { ...mb, ...updates } }) } const toggleProductType = (type: MachineProductType) => { const current = mb.productTypes || [] if (current.includes(type)) { updateMB({ productTypes: current.filter(t => t !== type) }) } else { updateMB({ productTypes: [...current, type] }) } } const toggleAIType = (type: AIIntegrationType) => { const current = mb.aiIntegrationType || [] if (current.includes(type)) { updateMB({ aiIntegrationType: current.filter(t => t !== type) }) } else { updateMB({ aiIntegrationType: [...current, type] }) } } const toggleCriticalSector = (sector: CriticalSector) => { const current = mb.criticalSectors || [] if (current.includes(sector)) { updateMB({ criticalSectors: current.filter(s => s !== sector) }) } else { updateMB({ criticalSectors: [...current, sector] }) } } return (
{/* Block 1: Erzaehlen Sie uns von Ihrer Anlage */}

Erzaehlen Sie uns von Ihrer Anlage

Je besser wir Ihr Produkt verstehen, desto praeziser koennen wir die relevanten Vorschriften identifizieren.