'use client' import { useState } from 'react' import { Play, Clock, BookOpen, Users, ChevronDown, Info } from 'lucide-react' import { LessonTemplate, PhaseDurations, Class } from '@/lib/companion/types' import { SYSTEM_TEMPLATES, DEFAULT_PHASE_DURATIONS, PHASE_DISPLAY_NAMES, PHASE_ORDER, calculateTotalDuration, formatMinutes, } from '@/lib/companion/constants' interface LessonStartFormProps { onStart: (data: { classId: string subject: string topic?: string templateId?: string }) => void loading?: boolean availableClasses?: Class[] } // Mock classes for development const MOCK_CLASSES: Class[] = [ { id: 'c1', name: '9a', grade: '9', studentCount: 28 }, { id: 'c2', name: '9b', grade: '9', studentCount: 26 }, { id: 'c3', name: '10a', grade: '10', studentCount: 24 }, { id: 'c4', name: 'Deutsch LK', grade: 'Q1', studentCount: 18 }, { id: 'c5', name: 'Mathe GK', grade: 'Q2', studentCount: 22 }, ] const SUBJECTS = [ 'Deutsch', 'Mathematik', 'Englisch', 'Biologie', 'Physik', 'Chemie', 'Geschichte', 'Geographie', 'Politik', 'Kunst', 'Musik', 'Sport', 'Informatik', 'Sonstiges', ] export function LessonStartForm({ onStart, loading, availableClasses = MOCK_CLASSES, }: LessonStartFormProps) { const [selectedClass, setSelectedClass] = useState('') const [selectedSubject, setSelectedSubject] = useState('') const [topic, setTopic] = useState('') const [selectedTemplate, setSelectedTemplate] = useState( SYSTEM_TEMPLATES[0] as LessonTemplate ) const [showTemplateDetails, setShowTemplateDetails] = useState(false) const totalDuration = selectedTemplate ? calculateTotalDuration(selectedTemplate.durations) : calculateTotalDuration(DEFAULT_PHASE_DURATIONS) const canStart = selectedClass && selectedSubject const handleSubmit = (e: React.FormEvent) => { e.preventDefault() if (!canStart) return onStart({ classId: selectedClass, subject: selectedSubject, topic: topic || undefined, templateId: selectedTemplate?.templateId, }) } return (

Neue Stunde starten

Waehlen Sie Klasse, Fach und Template

{/* Class Selection */}
{/* Subject Selection */}
{/* Topic (Optional) */}
setTopic(e.target.value)} placeholder="z.B. Quadratische Funktionen, Gedichtanalyse..." className="w-full px-4 py-3 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500" />
{/* Template Selection */}
{SYSTEM_TEMPLATES.map((template) => { const tpl = template as LessonTemplate const isSelected = selectedTemplate?.templateId === tpl.templateId const total = calculateTotalDuration(tpl.durations) return ( ) })}
{/* Template Details Toggle */} {selectedTemplate && ( )} {/* Template Details */} {showTemplateDetails && selectedTemplate && (
{PHASE_ORDER.map((phaseId) => (

{PHASE_DISPLAY_NAMES[phaseId]}

{selectedTemplate.durations[phaseId]} Min

))}
)}
{/* Summary & Start Button */}
Gesamtdauer: {formatMinutes(totalDuration)}
{selectedClass && (
Klasse: {availableClasses.find((c) => c.id === selectedClass)?.name}
)}
) }