'use client'
import type { UnitDefinition } from './types'
export function UnitsTab({
units,
selectedUnit,
isLoadingUnits,
unitsError,
onFetchUnits,
onFetchUnitDetails,
onClearSelection,
}: {
units: UnitDefinition[]
selectedUnit: UnitDefinition | null
isLoadingUnits: boolean
unitsError: string | null
onFetchUnits: () => void
onFetchUnitDetails: (unitId: string) => void
onClearSelection: () => void
}) {
return (
{/* Units Header */}
Unit-Definitionen
{/* Units Error */}
{unitsError && (
{unitsError}
Backend starten: cd backend && python main.py
)}
{/* Units Grid */}
{units.map((unit) => (
onFetchUnitDetails(unit.unit_id)}
>
{unit.unit_id}
{unit.template}
{unit.topic || unit.subject || 'Keine Beschreibung'}
{unit.duration_minutes} min
{unit.difficulty}
{unit.grade_band?.join(', ') || '-'}
))}
{/* Empty State */}
{!isLoadingUnits && units.length === 0 && !unitsError && (
Keine Units gefunden
Units werden unter backend/data/units/ gespeichert
)}
{/* Selected Unit Details */}
{selectedUnit && (
{/* Learning Objectives */}
{selectedUnit.learning_objectives && selectedUnit.learning_objectives.length > 0 && (
Lernziele
{selectedUnit.learning_objectives.map((obj, i) => (
- {obj}
))}
)}
{/* Stops */}
{selectedUnit.stops && selectedUnit.stops.length > 0 && (
Stops ({selectedUnit.stops.length})
{selectedUnit.stops.map((stop) => (
{stop.order + 1}
{stop.label?.['de-DE'] || stop.stop_id}
{stop.interaction && (
({stop.interaction.type})
)}
))}
)}
{/* JSON Preview */}
JSON anzeigen
{JSON.stringify(selectedUnit, null, 2)}
)}
)
}