'use client' import { useState, useEffect } from 'react' import { useParams, useRouter } from 'next/navigation' import Link from 'next/link' import { useLanguage } from '@/lib/LanguageContext' interface WizardStep { number: number id: string titleKey: string subtitleKey: string descKey: string icon: string is_required: boolean is_completed: boolean } interface FormData { [key: string]: any } const stepIcons: Record = { 'document-text': ( ), 'academic-cap': ( ), 'server': ( ), 'document-report': ( ), 'currency-euro': ( ), 'calculator': ( ), 'calendar': ( ), 'document-download': ( ), } export default function FoerderantragWizardPage() { const params = useParams() const router = useRouter() const { t, isRTL } = useLanguage() const applicationId = params.applicationId as string const defaultSteps: WizardStep[] = [ { number: 1, id: 'foerderprogramm', titleKey: 'fa_step1_title', subtitleKey: 'fa_step1_subtitle', descKey: 'fa_step1_desc', icon: 'document-text', is_required: true, is_completed: false }, { number: 2, id: 'schulinformationen', titleKey: 'fa_step2_title', subtitleKey: 'fa_step2_subtitle', descKey: 'fa_step2_desc', icon: 'academic-cap', is_required: true, is_completed: false }, { number: 3, id: 'bestandsaufnahme', titleKey: 'fa_step3_title', subtitleKey: 'fa_step3_subtitle', descKey: 'fa_step3_desc', icon: 'server', is_required: true, is_completed: false }, { number: 4, id: 'projektbeschreibung', titleKey: 'fa_step4_title', subtitleKey: 'fa_step4_subtitle', descKey: 'fa_step4_desc', icon: 'document-report', is_required: true, is_completed: false }, { number: 5, id: 'investitionen', titleKey: 'fa_step5_title', subtitleKey: 'fa_step5_subtitle', descKey: 'fa_step5_desc', icon: 'currency-euro', is_required: true, is_completed: false }, { number: 6, id: 'finanzierungsplan', titleKey: 'fa_step6_title', subtitleKey: 'fa_step6_subtitle', descKey: 'fa_step6_desc', icon: 'calculator', is_required: true, is_completed: false }, { number: 7, id: 'zeitplan', titleKey: 'fa_step7_title', subtitleKey: 'fa_step7_subtitle', descKey: 'fa_step7_desc', icon: 'calendar', is_required: true, is_completed: false }, { number: 8, id: 'abschluss', titleKey: 'fa_step8_title', subtitleKey: 'fa_step8_subtitle', descKey: 'fa_step8_desc', icon: 'document-download', is_required: true, is_completed: false }, ] const [currentStep, setCurrentStep] = useState(1) const [steps, setSteps] = useState(defaultSteps) const [formData, setFormData] = useState({}) const [isSaving, setIsSaving] = useState(false) const [showAssistant, setShowAssistant] = useState(false) const [assistantMessage, setAssistantMessage] = useState('') const [assistantHistory, setAssistantHistory] = useState<{ role: string; content: string }[]>([]) const [isDemo, setIsDemo] = useState(false) useEffect(() => { if (applicationId.startsWith('demo-')) { setIsDemo(true) } }, [applicationId]) const handleFieldChange = (fieldId: string, value: any) => { setFormData(prev => ({ ...prev, [`step_${currentStep}`]: { ...prev[`step_${currentStep}`], [fieldId]: value, }, })) } const handleSaveStep = async () => { setIsSaving(true) try { setSteps(prev => prev.map(s => s.number === currentStep ? { ...s, is_completed: true } : s )) } finally { setIsSaving(false) } } const handleNextStep = async () => { await handleSaveStep() if (currentStep < 8) { setCurrentStep(prev => prev + 1) } } const handlePrevStep = () => { if (currentStep > 1) { setCurrentStep(prev => prev - 1) } } const handleAskAssistant = async () => { if (!assistantMessage.trim()) return const userMessage = assistantMessage setAssistantMessage('') setAssistantHistory(prev => [...prev, { role: 'user', content: userMessage }]) setTimeout(() => { const response = `${t('fa_assistant_title')}: ${userMessage}` setAssistantHistory(prev => [...prev, { role: 'assistant', content: response }]) }, 1000) } const currentStepData = steps.find(s => s.number === currentStep) const renderStepContent = () => { switch (currentStep) { case 1: return case 2: return case 3: return case 4: return case 5: return case 6: return case 7: return case 8: return default: return null } } return (
{/* Header */}

{t('fa_wizard_header')}

{t('fa_step1_title').split('')[0] && `${currentStep} ${t('fa_wizard_step_of')} ${steps.length}: ${currentStepData ? t(currentStepData.titleKey) : ''}`}

{isDemo && ( {t('fa_demo_mode')} )}
{/* Progress Steps */}
{steps.map((step) => ( ))}
{/* Main Content */}
{/* Form Area */}
{/* Step Header */}
{stepIcons[currentStepData?.icon || 'document-text']}

{currentStepData ? t(currentStepData.titleKey) : ''}

{currentStepData ? t(currentStepData.descKey) : ''}

{/* Step Content */}
{renderStepContent()}
{/* Navigation */}
{/* Assistant Sidebar */} {showAssistant && (

{t('fa_assistant_title')}

{/* Chat History */}
{assistantHistory.length === 0 && (

{t('fa_assistant_placeholder')}

)} {assistantHistory.map((msg, idx) => (
{msg.content}
))}
{/* Input */}
setAssistantMessage(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && handleAskAssistant()} placeholder={t('fa_assistant_placeholder')} className="flex-1 px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500" />
)}
) } // Step Components function Step1({ t }: { t: (key: string) => string }) { return (

{t('fa_step1_desc')}

{t('fa_wizard_next')}

) } function Step2({ t }: { t: (key: string) => string }) { return (
) } function Step3({ t }: { t: (key: string) => string }) { return (
) } function Step4({ t }: { t: (key: string) => string }) { return (