'use client' import { LegalTemplateResult } from '@/lib/sdk/types' import { CATEGORIES } from '../_constants' import LibraryCard from './LibraryCard' interface TemplateLibraryProps { allTemplates: LegalTemplateResult[] filteredTemplates: LegalTemplateResult[] isLoadingLibrary: boolean activeCategory: string onCategoryChange: (cat: string) => void activeLanguage: 'all' | 'de' | 'en' onLanguageChange: (lang: 'all' | 'de' | 'en') => void librarySearch: string onSearchChange: (q: string) => void expandedPreviewId: string | null onTogglePreview: (id: string) => void onUseTemplate: (t: LegalTemplateResult) => void } export default function TemplateLibrary({ allTemplates, filteredTemplates, isLoadingLibrary, activeCategory, onCategoryChange, activeLanguage, onLanguageChange, librarySearch, onSearchChange, expandedPreviewId, onTogglePreview, onUseTemplate, }: TemplateLibraryProps) { return (

Template-Bibliothek

{(['all', 'de', 'en'] as const).map((lang) => ( ))}
{/* Category pills */}
{CATEGORIES.map((cat) => { const count = cat.types === null ? allTemplates.filter(t => activeLanguage === 'all' || t.language === activeLanguage).length : allTemplates.filter(t => cat.types!.includes(t.templateType || '') && (activeLanguage === 'all' || t.language === activeLanguage) ).length return ( ) })}
{/* Search */}
onSearchChange(e.target.value)} placeholder="Vorlage suchen... (optional)" className="w-full pl-9 pr-4 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-purple-400" /> {librarySearch && ( )}
{/* Template grid */}
{isLoadingLibrary ? (
) : filteredTemplates.length === 0 ? (
📄

Keine Vorlagen für diese Auswahl

) : (
{filteredTemplates.map((template) => ( onTogglePreview(template.id)} onUse={() => onUseTemplate(template)} /> ))}
)}
) }