'use client' import { useState } from 'react' import { CheckCircle, Clock, BarChart3, Plus, RefreshCw } from 'lucide-react' import { LessonSession } from '@/lib/companion/types' import { HomeworkSection } from './HomeworkSection' import { ReflectionSection } from './ReflectionSection' import { PHASE_COLORS, PHASE_DISPLAY_NAMES, formatTime, formatMinutes, } from '@/lib/companion/constants' interface LessonEndedViewProps { session: LessonSession onSaveReflection: (rating: number, notes: string, nextSteps: string) => void onAddHomework: (title: string, dueDate: string) => void onRemoveHomework: (id: string) => void onStartNew: () => void } export function LessonEndedView({ session, onSaveReflection, onAddHomework, onRemoveHomework, onStartNew, }: LessonEndedViewProps) { const [activeTab, setActiveTab] = useState<'summary' | 'homework' | 'reflection'>('summary') // Calculate analytics const totalPlannedSeconds = session.totalPlannedDuration * 60 const totalActualSeconds = session.elapsedTime const timeDiff = totalActualSeconds - totalPlannedSeconds const timeDiffMinutes = Math.round(timeDiff / 60) const startTime = new Date(session.startTime) const endTime = session.endTime ? new Date(session.endTime) : new Date() return (
{/* Success Header */}

Stunde beendet!

{session.className} - {session.subject} {session.topic && ` - ${session.topic}`}

{/* Tab Navigation */}
{[ { id: 'summary', label: 'Zusammenfassung', icon: BarChart3 }, { id: 'homework', label: 'Hausaufgaben', icon: Plus }, { id: 'reflection', label: 'Reflexion', icon: RefreshCw }, ].map((tab) => ( ))}
{/* Tab Content */} {activeTab === 'summary' && (
{/* Time Overview */}

Zeitauswertung

{formatTime(totalActualSeconds)}
Tatsaechlich
{formatMinutes(session.totalPlannedDuration)}
Geplant
0 ? 'bg-amber-50' : 'bg-green-50'}`}>
0 ? 'text-amber-600' : 'text-green-600'}`}> {timeDiffMinutes > 0 ? '+' : ''}{timeDiffMinutes} Min
0 ? 'text-amber-500' : 'text-green-500'}`}> Differenz
{/* Session Times */}
Start: {startTime.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' })} Ende: {endTime.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' })}
{/* Phase Breakdown */}

Phasen-Analyse

{session.phases.map((phase) => { const plannedSeconds = phase.duration * 60 const actualSeconds = phase.actualTime const diff = actualSeconds - plannedSeconds const diffMinutes = Math.round(diff / 60) const percentage = Math.min((actualSeconds / plannedSeconds) * 100, 150) return (
{PHASE_DISPLAY_NAMES[phase.phase]}
{Math.round(actualSeconds / 60)} / {phase.duration} Min 60 ? 'bg-amber-100 text-amber-700' : diff < -60 ? 'bg-blue-100 text-blue-700' : 'bg-green-100 text-green-700'} `}> {diffMinutes > 0 ? '+' : ''}{diffMinutes} Min
{/* Progress Bar */}
100 ? '#f59e0b' // amber for overtime : PHASE_COLORS[phase.phase].hex, }} />
) })}
)} {activeTab === 'homework' && ( )} {activeTab === 'reflection' && ( )} {/* Start New Lesson Button */}
) }