"use client"; import { useState } from "react"; import type { Personality, FormalityLevel } from "@mosaic/shared"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Switch } from "@/components/ui/switch"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; export interface PersonalityFormData { name: string; description?: string; tone: string; formalityLevel: FormalityLevel; systemPromptTemplate: string; isDefault?: boolean; isActive?: boolean; } interface PersonalityFormProps { personality?: Personality; onSubmit: (data: PersonalityFormData) => Promise; onCancel?: () => void; } const FORMALITY_OPTIONS = [ { value: "VERY_CASUAL", label: "Very Casual" }, { value: "CASUAL", label: "Casual" }, { value: "NEUTRAL", label: "Neutral" }, { value: "FORMAL", label: "Formal" }, { value: "VERY_FORMAL", label: "Very Formal" }, ]; export function PersonalityForm({ personality, onSubmit, onCancel }: PersonalityFormProps): React.ReactElement { const [formData, setFormData] = useState({ name: personality?.name || "", description: personality?.description || "", tone: personality?.tone || "", formalityLevel: (personality?.formalityLevel ?? "NEUTRAL") as FormalityLevel, systemPromptTemplate: personality?.systemPromptTemplate || "", isDefault: personality?.isDefault || false, isActive: personality?.isActive ?? true, }); const [isSubmitting, setIsSubmitting] = useState(false); async function handleSubmit(e: React.FormEvent): Promise { e.preventDefault(); setIsSubmitting(true); try { await onSubmit(formData); } finally { setIsSubmitting(false); } } return (
{personality ? "Edit Personality" : "Create New Personality"} Customize how the AI assistant communicates and responds {/* Name */}
setFormData({ ...formData, name: e.target.value })} placeholder="e.g., Professional, Casual, Friendly" required />
{/* Description */}