From 137fb05f8bfc917edde778d6df8c245804d4af2d Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 16 Oct 2025 18:46:14 +0000 Subject: [PATCH] Refactor chat view and add features --- src/components/Layout.tsx | 12 -- src/components/chat/ChatSidebar.tsx | 324 ++++++++++++++++++++++++++++ src/components/chat/ChatView.tsx | 57 ++--- 3 files changed, 356 insertions(+), 37 deletions(-) create mode 100644 src/components/chat/ChatSidebar.tsx diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index a92a3e7..5e23ff9 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -60,18 +60,6 @@ export const Layout = ({ children, activeTab, onTabChange }: LayoutProps) => { - {/* Recent Section */} -
-

- Recentes -

-
-
- Conversa anterior... -
-
-
- {/* Settings */}
+ + + + Criar Nova Pasta + + Organize suas conversas em pastas personalizadas. + + +
+
+ + setNewFolderName(e.target.value)} + placeholder="Ex: Projetos, Estudos..." + onKeyDown={(e) => e.key === "Enter" && handleCreateFolder()} + /> +
+
+ + + + +
+ +
+ + {/* Conversations List */} + +
+ {/* Folders */} + {folders.map((folder) => ( +
+ + + {expandedFolders.has(folder.id) && conversationsByFolder[folder.id]?.length > 0 && ( +
+ {conversationsByFolder[folder.id].map((conv) => ( + setSelectedConversation(conv.id)} + folders={folders} + onMoveToFolder={moveToFolder} + onRemoveFromFolder={removeFromFolder} + /> + ))} +
+ )} +
+ ))} + + {/* Conversations without folder */} + {conversationsWithoutFolder.length > 0 && ( +
+
+ Sem Pasta +
+ {conversationsWithoutFolder.map((conv) => ( + setSelectedConversation(conv.id)} + folders={folders} + onMoveToFolder={moveToFolder} + onRemoveFromFolder={removeFromFolder} + /> + ))} +
+ )} +
+
+ + ); +}; + +interface ConversationItemProps { + conversation: Conversation; + isSelected: boolean; + onSelect: () => void; + folders: ChatFolder[]; + onMoveToFolder: (conversationId: string, folderId: string) => void; + onRemoveFromFolder: (conversationId: string) => void; +} + +const ConversationItem = ({ + conversation, + isSelected, + onSelect, + folders, + onMoveToFolder, + onRemoveFromFolder, +}: ConversationItemProps) => { + return ( +
+ +
+

{conversation.title}

+

+ {conversation.lastMessage} +

+

+ {conversation.timestamp} +

+
+ + + e.stopPropagation()}> + + + + + + Renomear + + + {conversation.folderId && ( + onRemoveFromFolder(conversation.id)} + > + + Remover da Pasta + + )} + + {folders.map((folder) => ( + onMoveToFolder(conversation.id, folder.id)} + > + + Mover para {folder.name} + + ))} + + + + Excluir + + + +
+ ); +}; diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx index c876a53..84a53cc 100644 --- a/src/components/chat/ChatView.tsx +++ b/src/components/chat/ChatView.tsx @@ -2,6 +2,7 @@ import { useState } from "react"; import { ChatHeader } from "@/components/ChatHeader"; import { ChatMessage } from "./ChatMessage"; import { ChatInput } from "./ChatInput"; +import { ChatSidebar } from "./ChatSidebar"; import { ScrollArea } from "@/components/ui/scroll-area"; interface Message { @@ -45,35 +46,41 @@ export const ChatView = () => { }; return ( -
- +
+ {/* Chat Sidebar */} + - -
- {messages.map((message) => ( - - ))} + {/* Main Chat Area */} +
+ - {isLoading && ( -
-
-
+ +
+ {messages.map((message) => ( + + ))} + + {isLoading && ( +
+
+
+
+
+
+
+
+
-
-
-
-
-
-
- )} -
- + )} +
+ - + +
); };