Reverted to commit 6c23bea1bc
This commit is contained in:
@@ -5,7 +5,7 @@ import { Textarea } from "@/components/ui/textarea";
|
|||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { ArrowLeft, Save, History, Power } from "lucide-react";
|
import { ArrowLeft, Save, History, Power, Pencil, Check, X } from "lucide-react";
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
import { VersionHistoryDialog } from "@/components/agents/VersionHistoryDialog";
|
import { VersionHistoryDialog } from "@/components/agents/VersionHistoryDialog";
|
||||||
import { SaveVersionDialog } from "@/components/agents/SaveVersionDialog";
|
import { SaveVersionDialog } from "@/components/agents/SaveVersionDialog";
|
||||||
@@ -28,6 +28,8 @@ export default function AgentDetails() {
|
|||||||
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
||||||
const [isSaveVersionOpen, setIsSaveVersionOpen] = useState(false);
|
const [isSaveVersionOpen, setIsSaveVersionOpen] = useState(false);
|
||||||
const [isDeactivateDialogOpen, setIsDeactivateDialogOpen] = useState(false);
|
const [isDeactivateDialogOpen, setIsDeactivateDialogOpen] = useState(false);
|
||||||
|
const [isEditingName, setIsEditingName] = useState(false);
|
||||||
|
const [tempName, setTempName] = useState("");
|
||||||
|
|
||||||
// Mock data - substituir por dados reais do backend
|
// Mock data - substituir por dados reais do backend
|
||||||
const [agent, setAgent] = useState<{
|
const [agent, setAgent] = useState<{
|
||||||
@@ -117,6 +119,26 @@ export default function AgentDetails() {
|
|||||||
setIsDeactivateDialogOpen(false);
|
setIsDeactivateDialogOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleStartEditName = () => {
|
||||||
|
setTempName(agent.name);
|
||||||
|
setIsEditingName(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSaveName = () => {
|
||||||
|
if (tempName.trim()) {
|
||||||
|
setAgent({ ...agent, name: tempName.trim() });
|
||||||
|
setIsEditingName(false);
|
||||||
|
toast({
|
||||||
|
title: "Nome atualizado",
|
||||||
|
description: "O nome do agente foi alterado com sucesso.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancelEditName = () => {
|
||||||
|
setIsEditingName(false);
|
||||||
|
setTempName("");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="animate-fade-in pb-8">
|
<div className="animate-fade-in pb-8">
|
||||||
@@ -133,12 +155,48 @@ export default function AgentDetails() {
|
|||||||
|
|
||||||
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Input
|
{isEditingName ? (
|
||||||
value={agent.name}
|
<div className="flex items-center gap-2">
|
||||||
onChange={(e) => setAgent({ ...agent, name: e.target.value })}
|
<Input
|
||||||
className="text-2xl md:text-3xl font-bold h-auto py-2 max-w-md"
|
value={tempName}
|
||||||
placeholder="Nome do agente"
|
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>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<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>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Badge
|
<Badge
|
||||||
variant={agent.status === "active" ? "default" : "secondary"}
|
variant={agent.status === "active" ? "default" : "secondary"}
|
||||||
className={
|
className={
|
||||||
|
|||||||
Reference in New Issue
Block a user