Edit agent name: save on Save Alterações
Update inline name editing to local state only; persist on Save Alterações button. Remove instant save behavior and inline confirm/cancel actions; simplify to editable input with local state updates and final save handled by existing SaveVersionDialog.
This commit is contained in:
+18
-39
@@ -5,7 +5,7 @@ import { Textarea } from "@/components/ui/textarea";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { ArrowLeft, Save, History, Power, Pencil, Check, X } from "lucide-react";
|
||||
import { ArrowLeft, Save, History, Power, Pencil } from "lucide-react";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { VersionHistoryDialog } from "@/components/agents/VersionHistoryDialog";
|
||||
import { SaveVersionDialog } from "@/components/agents/SaveVersionDialog";
|
||||
@@ -124,20 +124,13 @@ export default function AgentDetails() {
|
||||
setIsEditingName(true);
|
||||
};
|
||||
|
||||
const handleSaveName = () => {
|
||||
const handleNameBlur = () => {
|
||||
if (tempName.trim()) {
|
||||
setAgent({ ...agent, name: tempName.trim() });
|
||||
setIsEditingName(false);
|
||||
toast({
|
||||
title: "Nome atualizado",
|
||||
description: "O nome do agente foi alterado com sucesso.",
|
||||
});
|
||||
} else {
|
||||
setTempName(agent.name);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancelEditName = () => {
|
||||
setIsEditingName(false);
|
||||
setTempName("");
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -156,34 +149,20 @@ export default function AgentDetails() {
|
||||
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-3">
|
||||
{isEditingName ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
value={tempName}
|
||||
onChange={(e) => setTempName(e.target.value)}
|
||||
className="text-2xl md:text-3xl font-bold h-auto py-1"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") handleSaveName();
|
||||
if (e.key === "Escape") handleCancelEditName();
|
||||
}}
|
||||
autoFocus
|
||||
/>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 p-0"
|
||||
onClick={handleSaveName}
|
||||
>
|
||||
<Check className="h-4 w-4 text-green-600" />
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 p-0"
|
||||
onClick={handleCancelEditName}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
<Input
|
||||
value={tempName}
|
||||
onChange={(e) => setTempName(e.target.value)}
|
||||
className="text-2xl md:text-3xl font-bold h-auto py-1"
|
||||
onBlur={handleNameBlur}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") handleNameBlur();
|
||||
if (e.key === "Escape") {
|
||||
setTempName(agent.name);
|
||||
setIsEditingName(false);
|
||||
}
|
||||
}}
|
||||
autoFocus
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<h1 className="text-2xl md:text-3xl font-bold text-foreground">{agent.name}</h1>
|
||||
|
||||
Reference in New Issue
Block a user