'use client' import React, { useState } from 'react' import { useRouter } from 'next/navigation' import type { VocabWorksheetHook } from '../types' import { getApiBase } from '../constants' export function ExportTab({ h }: { h: VocabWorksheetHook }) { const { isDark, glassCard } = h const router = useRouter() const [isGeneratingLearning, setIsGeneratingLearning] = useState(false) const [learningUnitId, setLearningUnitId] = useState(null) const [learningError, setLearningError] = useState(null) const handleGenerateLearningUnit = async () => { if (!h.session) return setIsGeneratingLearning(true) setLearningError(null) try { const apiBase = getApiBase() const resp = await fetch(`${apiBase}/api/v1/vocab/sessions/${h.session.id}/generate-learning-unit`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ generate_modules: true }), }) if (!resp.ok) { const err = await resp.json().catch(() => ({})) throw new Error(err.detail || `HTTP ${resp.status}`) } const result = await resp.json() setLearningUnitId(result.unit_id) } catch (err: any) { setLearningError(err.message || 'Fehler bei der Generierung') } finally { setIsGeneratingLearning(false) } } return (
{/* PDF Download Section */}

PDF herunterladen

{h.worksheetId ? (
Arbeitsblatt erfolgreich generiert!
{h.includeSolutions && ( )}
) : (

Noch kein Arbeitsblatt generiert.

)}
{/* Learning Module Generation Section */}

Interaktive Lernmodule

Aus den Vokabeln automatisch Karteikarten, Quiz und Lueckentexte erstellen.

{learningError && (

{learningError}

)} {learningUnitId ? (
Lernmodule wurden generiert!
) : ( )}
{/* Reset Button */}
) }