'use client' import { useState } from 'react' import type { Collection, CreateCollectionData } from '../types' const API_BASE = process.env.NEXT_PUBLIC_KLAUSUR_SERVICE_URL || 'http://localhost:8086' interface CollectionsTabProps { collections: Collection[] loading: boolean onRefresh: () => void } function CollectionsTab({ collections, loading, onRefresh }: CollectionsTabProps) { const [showCreateModal, setShowCreateModal] = useState(false) const [creating, setCreating] = useState(false) const [createError, setCreateError] = useState(null) const [formData, setFormData] = useState({ name: 'bp_', display_name: '', bundesland: 'NI', use_case: '', description: '', }) const handleCreate = async () => { setCreating(true) setCreateError(null) try { const res = await fetch(`${API_BASE}/api/v1/admin/rag/collections`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(formData), }) if (res.ok) { setShowCreateModal(false) setFormData({ name: 'bp_', display_name: '', bundesland: 'NI', use_case: '', description: '', }) onRefresh() } else { const error = await res.json() setCreateError(error.detail || 'Fehler beim Erstellen') } } catch (err) { setCreateError('Netzwerkfehler') } finally { setCreating(false) } } const useCaseOptions = [ { value: 'klausur', label: 'Klausurkorrektur' }, { value: 'zeugnis', label: 'Zeugniserstellung' }, { value: 'material', label: 'Unterrichtsmaterial' }, { value: 'curriculum', label: 'Lehrplan' }, { value: 'other', label: 'Sonstiges' }, ] const bundeslandOptions = [ { value: 'NI', label: 'Niedersachsen' }, { value: 'NW', label: 'Nordrhein-Westfalen' }, { value: 'BY', label: 'Bayern' }, { value: 'BW', label: 'Baden-Württemberg' }, { value: 'HE', label: 'Hessen' }, { value: 'DE', label: 'Bundesweit' }, ] return (
{/* Header */}

RAG Sammlungen

Verwaltung der indexierten Dokumentensammlungen

{/* Loading State */} {loading && (
)} {/* Collections Grid */} {!loading && (
{collections.length === 0 ? (

Keine Sammlungen vorhanden

Erstellen Sie eine neue Sammlung, um Dokumente zu indexieren.

) : ( collections.map((col) => ( )) )} {/* Add new collection card */} {collections.length > 0 && ( )}
)} {/* Create Collection Modal */} {showCreateModal && (

Neue RAG-Sammlung erstellen

Erstellen Sie eine neue Sammlung für einen spezifischen Anwendungsfall

{createError && (
{createError}
)}
setFormData(prev => ({ ...prev, display_name: e.target.value }))} placeholder="z.B. Niedersachsen - Zeugniserstellung" className="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-primary-500" />
setFormData(prev => ({ ...prev, name: e.target.value }))} placeholder="bp_ni_zeugnis" className="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-primary-500 font-mono text-sm" />

Muss mit "bp_" beginnen. Nur Kleinbuchstaben und Unterstriche.