'use client' import React from 'react' import { LoeschfristPolicy, RETENTION_DRIVER_META, formatRetentionDuration, getEffectiveDeletionTrigger, } from '@/lib/sdk/loeschfristen-types' import { PROFILING_STEPS, ProfilingAnswer, ProfilingStep, isStepComplete, getProfilingProgress, } from '@/lib/sdk/loeschfristen-profiling' import { renderTriggerBadge } from './UebersichtTab' // --------------------------------------------------------------------------- // Types // --------------------------------------------------------------------------- interface GeneratorTabProps { profilingStep: number setProfilingStep: (s: number | ((prev: number) => number)) => void profilingAnswers: ProfilingAnswer[] handleProfilingAnswer: (stepIndex: number, questionId: string, value: any) => void generatedPolicies: LoeschfristPolicy[] setGeneratedPolicies: (p: LoeschfristPolicy[]) => void selectedGenerated: Set setSelectedGenerated: (s: Set) => void handleGenerate: () => void adoptGeneratedPolicies: (onlySelected: boolean) => void } // --------------------------------------------------------------------------- // Generated policies preview // --------------------------------------------------------------------------- function GeneratedPreview({ generatedPolicies, selectedGenerated, setSelectedGenerated, setGeneratedPolicies, adoptGeneratedPolicies, }: Pick< GeneratorTabProps, 'generatedPolicies' | 'selectedGenerated' | 'setSelectedGenerated' | 'setGeneratedPolicies' | 'adoptGeneratedPolicies' >) { return (

Generierte Loeschfristen

Auf Basis Ihres Profils wurden {generatedPolicies.length} Loeschfristen generiert. Waehlen Sie die relevanten aus und uebernehmen Sie sie.

{generatedPolicies.map((gp) => { const selected = selectedGenerated.has(gp.policyId) return ( ) })}
) } // --------------------------------------------------------------------------- // Profiling wizard // --------------------------------------------------------------------------- function ProfilingWizard({ profilingStep, setProfilingStep, profilingAnswers, handleProfilingAnswer, handleGenerate, }: Pick< GeneratorTabProps, 'profilingStep' | 'setProfilingStep' | 'profilingAnswers' | 'handleProfilingAnswer' | 'handleGenerate' >) { const totalSteps = PROFILING_STEPS.length const progress = getProfilingProgress(profilingAnswers) const allComplete = PROFILING_STEPS.every((step, idx) => isStepComplete(step, profilingAnswers.filter((a) => a.stepIndex === idx)), ) const currentStep: ProfilingStep | undefined = PROFILING_STEPS[profilingStep] return (
{/* Progress bar */}

Profiling-Assistent

Schritt {profilingStep + 1} von {totalSteps}
{PROFILING_STEPS.map((step, idx) => ( ))}
{/* Current step questions */} {currentStep && (

{currentStep.title}

{currentStep.description &&

{currentStep.description}

}
{currentStep.questions.map((question) => { const currentAnswer = profilingAnswers.find( (a) => a.stepIndex === profilingStep && a.questionId === question.id, ) return (
{question.type === 'boolean' && (
{[{ val: true, label: 'Ja' }, { val: false, label: 'Nein' }].map((opt) => ( ))}
)} {question.type === 'single' && question.options && (
{question.options.map((opt) => ( ))}
)} {question.type === 'multi' && question.options && (
{question.options.map((opt) => { const selectedValues: string[] = currentAnswer?.value || [] const isSelected = selectedValues.includes(opt.value) return ( ) })}
)} {question.type === 'number' && ( handleProfilingAnswer(profilingStep, question.id, e.target.value ? parseInt(e.target.value) : '')} min={0} placeholder="Bitte Zahl eingeben" className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500" /> )}
) })}
)} {/* Navigation */}
{profilingStep < totalSteps - 1 ? ( ) : ( )}
) } // --------------------------------------------------------------------------- // Main export // --------------------------------------------------------------------------- export function GeneratorTab(props: GeneratorTabProps) { if (props.generatedPolicies.length > 0) { return } return }