/** * Template-Service für Chat-Vorlagen */ import { supabase } from '../utils/supabase'; // Typdefinition für eine Vorlage export interface Template { id: string; user_id: string; name: string; description: string | null; system_prompt: string; initial_question: string | null; model_id: string | null; color: string; is_default: boolean; document_mode: boolean; created_at: string; updated_at: string; } /** * Lädt alle Vorlagen eines Benutzers * @param userId Die ID des Benutzers * @returns Liste der Vorlagen */ export async function getTemplates(userId: string): Promise { try { const { data, error } = await supabase .from('templates') .select('*') .eq('user_id', userId) .order('name'); if (error) { console.error('Fehler beim Laden der Vorlagen:', error); return []; } return data as Template[]; } catch (error) { console.error('Fehler beim Laden der Vorlagen:', error); return []; } } /** * Lädt eine bestimmte Vorlage anhand ihrer ID * @param templateId Die ID der Vorlage * @returns Die Vorlage oder null, wenn nicht gefunden */ export async function getTemplateById(templateId: string): Promise