'use client' import { useState } from 'react' import type { EHSuggestion } from '@/app/korrektur/types' import { DEFAULT_CRITERIA, ANNOTATION_COLORS, NIBIS_ATTRIBUTION } from '@/app/korrektur/types' interface EHSuggestionPanelProps { suggestions: EHSuggestion[] isLoading: boolean onLoadSuggestions: (criterion?: string) => void onInsertSuggestion?: (text: string) => void className?: string } export function EHSuggestionPanel({ suggestions, isLoading, onLoadSuggestions, onInsertSuggestion, className = '', }: EHSuggestionPanelProps) { const [selectedCriterion, setSelectedCriterion] = useState(undefined) const [expandedSuggestion, setExpandedSuggestion] = useState(null) const handleLoadSuggestions = () => { onLoadSuggestions(selectedCriterion) } // Group suggestions by criterion const groupedSuggestions = suggestions.reduce((acc, suggestion) => { if (!acc[suggestion.criterion]) { acc[suggestion.criterion] = [] } acc[suggestion.criterion].push(suggestion) return acc }, {} as Record) return (
{/* Header with Attribution (CTRL-SRC-002) */}

EH-Vorschlaege

Aus 500+ NiBiS Dokumenten

{/* Attribution Notice */}
Quelle: {NIBIS_ATTRIBUTION.publisher} •{' '} {NIBIS_ATTRIBUTION.license}
{/* Criterion Filter */}
{Object.entries(DEFAULT_CRITERIA).map(([id, config]) => { const color = ANNOTATION_COLORS[id as keyof typeof ANNOTATION_COLORS] || '#6b7280' return ( ) })}
{/* Load Button */} {/* Suggestions List */} {suggestions.length > 0 && (
{Object.entries(groupedSuggestions).map(([criterion, criterionSuggestions]) => { const config = DEFAULT_CRITERIA[criterion] const color = ANNOTATION_COLORS[criterion as keyof typeof ANNOTATION_COLORS] || '#6b7280' return (
{/* Criterion Header */}
{config?.name || criterion} ({criterionSuggestions.length})
{/* Suggestions */} {criterionSuggestions.map((suggestion, index) => ( setExpandedSuggestion( expandedSuggestion === `${criterion}-${index}` ? null : `${criterion}-${index}` ) } onInsert={onInsertSuggestion} /> ))}
) })}
)} {/* Empty State */} {!isLoading && suggestions.length === 0 && (

Klicken Sie auf "EH-Vorschlaege laden" um
relevante Bewertungskriterien zu finden.

)}
) } // ============================================================================= // SUGGESTION CARD // ============================================================================= interface SuggestionCardProps { suggestion: EHSuggestion color: string isExpanded: boolean onToggle: () => void onInsert?: (text: string) => void } function SuggestionCard({ suggestion, color, isExpanded, onToggle, onInsert, }: SuggestionCardProps) { const relevancePercent = Math.round(suggestion.relevance_score * 100) return (
{/* Header */} {/* Expanded Content */} {isExpanded && (

{suggestion.excerpt}

{/* Source Attribution */}
{suggestion.source_document || 'NiBiS Kerncurriculum'} ({NIBIS_ATTRIBUTION.license})
{/* Actions */} {onInsert && (
)}
)}
) }