'use client' import { useState, useCallback } from 'react' import Link from 'next/link' import { WizardStep, TestResult, STEPS, BACKEND_URL, GAME_URL, WizardStepper, EducationCard, TestResultCard, InteractiveDemo, } from './_components/WizardComponents' export default function GameWizardPage() { const [currentStep, setCurrentStep] = useState(0) const [steps, setSteps] = useState(STEPS) const [testResults, setTestResults] = useState([]) const [isLoading, setIsLoading] = useState(false) const currentStepData = steps[currentStep] const isWelcome = currentStepData?.id === 'welcome' const isSummary = currentStepData?.id === 'summary' const runWebGLTest = useCallback(async () => { setIsLoading(true) const results: TestResult[] = [] try { await fetch(GAME_URL, { mode: 'no-cors' }) results.push({ name: 'Game Server Erreichbarkeit', status: 'passed', message: 'Der Game-Server antwortet', details: GAME_URL }) } catch { results.push({ name: 'Game Server Erreichbarkeit', status: 'failed', message: 'Game-Server nicht erreichbar. Container gestartet?', details: 'docker-compose --profile game up -d' }) } results.push({ name: 'Iframe Embedding', status: 'passed', message: 'Iframe-Einbettung ist konfiguriert', details: '?embed=true' }) setTestResults(results) setIsLoading(false) const allPassed = results.every(r => r.status === 'passed') setSteps(prev => prev.map(s => s.id === 'webgl' ? { ...s, status: allPassed ? 'completed' : 'failed' } : s)) }, []) const runAPITest = useCallback(async () => { setIsLoading(true) const results: TestResult[] = [] try { const response = await fetch(`${BACKEND_URL}/api/game/learning-level?user_id=test-user`) if (response.ok) { const data = await response.json() results.push({ name: 'Learning Level Endpoint', status: 'passed', message: 'API antwortet korrekt', details: `Level: ${data.overall_level || 'Mock'}` }) } else { results.push({ name: 'Learning Level Endpoint', status: 'failed', message: `HTTP ${response.status}` }) } } catch { results.push({ name: 'Learning Level Endpoint', status: 'failed', message: 'Backend nicht erreichbar', details: 'docker-compose up -d backend' }) } try { const response = await fetch(`${BACKEND_URL}/api/game/questions?difficulty=3&count=2`) if (response.ok) { const data = await response.json() results.push({ name: 'Questions Endpoint', status: 'passed', message: 'Quiz-Fragen API funktioniert', details: `${data.questions?.length || 0} Fragen` }) } else { results.push({ name: 'Questions Endpoint', status: 'failed', message: `HTTP ${response.status}` }) } } catch { results.push({ name: 'Questions Endpoint', status: 'failed', message: 'Endpoint nicht erreichbar' }) } try { const response = await fetch(`${BACKEND_URL}/api/game/leaderboard?limit=5`) if (response.ok) { results.push({ name: 'Leaderboard Endpoint', status: 'passed', message: 'Leaderboard API funktioniert' }) } else { results.push({ name: 'Leaderboard Endpoint', status: 'failed', message: `HTTP ${response.status}` }) } } catch { results.push({ name: 'Leaderboard Endpoint', status: 'failed', message: 'Endpoint nicht erreichbar' }) } setTestResults(results) setIsLoading(false) const passedCount = results.filter(r => r.status === 'passed').length setSteps(prev => prev.map(s => s.id === 'api' ? { ...s, status: passedCount >= 2 ? 'completed' : 'failed' } : s)) }, []) const goToNext = () => { if (currentStep < steps.length - 1) { setSteps(prev => prev.map((step, idx) => idx === currentStep && step.status === 'pending' ? { ...step, status: 'completed' } : step )) setCurrentStep(prev => prev + 1) setTestResults([]) } } const goToPrev = () => { if (currentStep > 0) { setCurrentStep(prev => prev - 1) setTestResults([]) } } const handleStepClick = (index: number) => { setCurrentStep(index) setTestResults([]) } return (
{/* Header */}

๐ŸŽฎ Breakpilot Drive - Lern-Wizard

Interaktive Tour durch alle Game-Features

โ† Zurueck zum Dashboard
{/* Stepper */}
{/* Content */}
{/* Step Header */}
{currentStepData?.icon}

Schritt {currentStep + 1}: {currentStepData?.name}

{currentStep + 1} von {steps.length}

{/* Test Section */} {currentStepData?.testable && (
{testResults.length === 0 ? (
) : ( )}
)} {/* Welcome Start Button */} {isWelcome && (
)} {/* Summary Actions */} {isSummary && (
๐Ÿ“Š Zum Dashboard
)} {/* Navigation */} {!isWelcome && (
{!isSummary && ( )}
)}
{/* Footer Info */}
Breakpilot Drive - Endless Runner Lernspiel fuer Klasse 2-6
) }