import { useT } from "@agent-native/core/client/i18n"; import { IconLoader2, IconMessage2, IconPencil, IconPlus, IconTrash, } from "@tabler/icons-react"; import { useEffect, useRef, useState } from "react"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Skeleton } from "@/components/ui/skeleton"; import { Textarea } from "@/components/ui/textarea"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { useCreateSnippet, useDeleteSnippet, useSnippets, useUpdateSnippet, type Snippet, } from "@/hooks/use-snippets"; function SnippetEditRow({ snippet, onSave, onCancel, isPending, }: { snippet?: Snippet; onSave: (name: string, body: string) => void; onCancel: () => void; isPending?: boolean; }) { const t = useT(); const [name, setName] = useState(snippet?.name ?? ""); const [body, setBody] = useState(snippet?.body ?? ""); const handleSave = () => { if (!name.trim() || !body.trim()) return; onSave(name.trim(), body); }; return (
setName(e.target.value)} placeholder={t("settings.snippetNamePlaceholder")} className="px-3 py-1.5 text-[13px] placeholder:text-muted-foreground/40" />