import { createClient } from "@/utils/supabase/server"; import { redirect } from "next/navigation"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { Textarea } from "@/components/ui/textarea"; import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import { Save } from "lucide-react"; import type { AgentConfig } from "@/lib/types"; async function getConfig() { const supabase = await createClient(); const { data: { user } } = await supabase.auth.getUser(); if (!user || user.app_metadata?.role !== "admin") { redirect("/dashboard"); } const { data, error } = await supabase .from("agent_config") .select("*") .single(); if (error && error.code !== "PGRST116") { redirect("/dashboard"); } return data as AgentConfig | null; } const DAY_LABELS: Record = { mon: "Lunes", tue: "Martes", wed: "Miércoles", thu: "Jueves", fri: "Viernes", sat: "Sábado", sun: "Domingo", }; const DAY_ORDER = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]; /** * Página de configuración del agente IA y del consultorio (RF-09.5). * Solo accesible para rol admin. */ export default async function SettingsPage() { const config = await getConfig(); const workingHours = config?.working_hours ?? {}; return (

Configuración

Configura el agente IA, horarios y parámetros del consultorio

{/* System Prompt */} Prompt del Agente IA Define la personalidad y restricciones del asistente virtual. Este texto se envía como contexto en cada conversación.