import { useState } from "react"; import { Bot, Edit, MessageSquare, Trash2, ChevronLeft, ChevronRight } from "lucide-react"; 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 { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; interface Bot { id: string; name: string; prompt: string; model: string; } interface BotViewProps { onStartChat: (bot: Bot) => void; } export const BotView = ({ onStartChat }: BotViewProps) => { const [bots, setBots] = useState([]); const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false); const [isEditDialogOpen, setIsEditDialogOpen] = useState(false); const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false); const [selectedBot, setSelectedBot] = useState(null); const [currentPage, setCurrentPage] = useState(1); const [itemsPerPage, setItemsPerPage] = useState(10); const [formData, setFormData] = useState({ name: "", prompt: "", model: "ChatGPT 4.1", }); // Pagination calculations const totalPages = Math.ceil(bots.length / itemsPerPage); const startIndex = (currentPage - 1) * itemsPerPage; const endIndex = startIndex + itemsPerPage; const currentBots = bots.slice(startIndex, endIndex); // Reset to page 1 when items per page changes const handleItemsPerPageChange = (value: string) => { setItemsPerPage(Number(value)); setCurrentPage(1); }; const handleCreateBot = () => { const newBot: Bot = { id: Date.now().toString(), name: formData.name, prompt: formData.prompt, model: formData.model, }; setBots([...bots, newBot]); setFormData({ name: "", prompt: "", model: "ChatGPT 4.1" }); setIsCreateDialogOpen(false); }; const handleEditBot = () => { if (!selectedBot) return; setBots(bots.map(bot => bot.id === selectedBot.id ? { ...bot, name: formData.name, prompt: formData.prompt, model: formData.model } : bot )); setIsEditDialogOpen(false); setSelectedBot(null); setFormData({ name: "", prompt: "", model: "ChatGPT 4.1" }); }; const handleDeleteBot = () => { if (!selectedBot) return; setBots(bots.filter(bot => bot.id !== selectedBot.id)); setIsDeleteDialogOpen(false); setSelectedBot(null); }; const openEditDialog = (bot: Bot) => { setSelectedBot(bot); setFormData({ name: bot.name, prompt: bot.prompt, model: bot.model, }); setIsEditDialogOpen(true); }; const openDeleteDialog = (bot: Bot) => { setSelectedBot(bot); setIsDeleteDialogOpen(true); }; return (

Gerenciador de Bots

Crie e gerencie seus assistentes de IA

Criar Novo Bot Configure seu assistente de IA personalizado
setFormData({ ...formData, name: e.target.value })} placeholder="Ex: Assistente de Programação" />