Atualize Nome do Agente para Input Permanente
Remove edit mode e utilize campo de texto editável diretamente; salvar coletivamente com "Salvar Alterações" junto aos demais campos.
This commit is contained in:
@@ -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 } from "lucide-react";
|
||||
import { ArrowLeft, Save, History, Power } from "lucide-react";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { VersionHistoryDialog } from "@/components/agents/VersionHistoryDialog";
|
||||
import { SaveVersionDialog } from "@/components/agents/SaveVersionDialog";
|
||||
@@ -28,8 +28,6 @@ export default function AgentDetails() {
|
||||
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
||||
const [isSaveVersionOpen, setIsSaveVersionOpen] = useState(false);
|
||||
const [isDeactivateDialogOpen, setIsDeactivateDialogOpen] = useState(false);
|
||||
const [isEditingName, setIsEditingName] = useState(false);
|
||||
const [tempName, setTempName] = useState("");
|
||||
|
||||
// Mock data - substituir por dados reais do backend
|
||||
const [agent, setAgent] = useState<{
|
||||
@@ -119,19 +117,6 @@ export default function AgentDetails() {
|
||||
setIsDeactivateDialogOpen(false);
|
||||
};
|
||||
|
||||
const handleStartEditName = () => {
|
||||
setTempName(agent.name);
|
||||
setIsEditingName(true);
|
||||
};
|
||||
|
||||
const handleNameBlur = () => {
|
||||
if (tempName.trim()) {
|
||||
setAgent({ ...agent, name: tempName.trim() });
|
||||
} else {
|
||||
setTempName(agent.name);
|
||||
}
|
||||
setIsEditingName(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="animate-fade-in pb-8">
|
||||
@@ -148,34 +133,12 @@ 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 ? (
|
||||
<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>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 p-0"
|
||||
onClick={handleStartEditName}
|
||||
>
|
||||
<Pencil className="h-4 w-4" />
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Input
|
||||
value={agent.name}
|
||||
onChange={(e) => setAgent({ ...agent, name: e.target.value })}
|
||||
className="text-2xl md:text-3xl font-bold h-auto py-2 max-w-md"
|
||||
placeholder="Nome do agente"
|
||||
/>
|
||||
<Badge
|
||||
variant={agent.status === "active" ? "default" : "secondary"}
|
||||
className={
|
||||
|
||||
Reference in New Issue
Block a user