2025-03-11 11:02:30 +08:00
|
|
|
import React from "react";
|
|
|
|
|
|
2025-04-08 21:43:41 +08:00
|
|
|
// import { Sidebar } from "@/components/Assistant/Sidebar";
|
2025-03-11 11:02:30 +08:00
|
|
|
import type { Chat } from "./types";
|
2025-04-08 21:43:41 +08:00
|
|
|
import HistoryList from "../Common/HistoryList";
|
2025-03-11 11:02:30 +08:00
|
|
|
|
|
|
|
|
interface ChatSidebarProps {
|
|
|
|
|
isSidebarOpen: boolean;
|
|
|
|
|
chats: Chat[];
|
|
|
|
|
activeChat?: Chat;
|
2025-04-08 21:43:41 +08:00
|
|
|
// onNewChat: () => void;
|
2025-03-11 11:02:30 +08:00
|
|
|
onSelectChat: (chat: any) => void;
|
|
|
|
|
onDeleteChat: (chatId: string) => void;
|
|
|
|
|
fetchChatHistory: () => void;
|
2025-04-08 21:43:41 +08:00
|
|
|
onSearch: (keyword: string) => void;
|
|
|
|
|
onRename: (chat: any, title: string) => void;
|
2025-03-11 11:02:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const ChatSidebar: React.FC<ChatSidebarProps> = ({
|
|
|
|
|
isSidebarOpen,
|
|
|
|
|
chats,
|
|
|
|
|
activeChat,
|
2025-04-08 21:43:41 +08:00
|
|
|
// onNewChat,
|
2025-03-11 11:02:30 +08:00
|
|
|
onSelectChat,
|
|
|
|
|
onDeleteChat,
|
|
|
|
|
fetchChatHistory,
|
2025-04-08 21:43:41 +08:00
|
|
|
onSearch,
|
|
|
|
|
onRename,
|
2025-03-11 11:02:30 +08:00
|
|
|
}) => {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
data-sidebar
|
2025-04-07 11:19:09 +08:00
|
|
|
className={`
|
|
|
|
|
h-[calc(100%+90px)] absolute top-0 left-0 z-10 w-64
|
|
|
|
|
transform transition-all duration-300 ease-in-out
|
|
|
|
|
${isSidebarOpen ? "translate-x-0" : "-translate-x-full"}
|
|
|
|
|
bg-gray-100 dark:bg-gray-800
|
|
|
|
|
border-r border-gray-200 dark:border-gray-700 rounded-tl-xl rounded-bl-xl
|
|
|
|
|
overflow-hidden
|
|
|
|
|
`}
|
2025-03-11 11:02:30 +08:00
|
|
|
>
|
2025-04-08 21:43:41 +08:00
|
|
|
<HistoryList
|
|
|
|
|
list={chats}
|
|
|
|
|
active={activeChat}
|
|
|
|
|
onSearch={onSearch}
|
|
|
|
|
onRefresh={fetchChatHistory}
|
|
|
|
|
onSelect={onSelectChat}
|
|
|
|
|
onRename={onRename}
|
|
|
|
|
onRemove={onDeleteChat}
|
|
|
|
|
/>
|
|
|
|
|
{/* <Sidebar
|
2025-03-11 11:02:30 +08:00
|
|
|
chats={chats}
|
|
|
|
|
activeChat={activeChat}
|
|
|
|
|
onNewChat={onNewChat}
|
|
|
|
|
onSelectChat={onSelectChat}
|
|
|
|
|
onDeleteChat={onDeleteChat}
|
|
|
|
|
fetchChatHistory={fetchChatHistory}
|
2025-04-08 21:43:41 +08:00
|
|
|
/> */}
|
2025-03-11 11:02:30 +08:00
|
|
|
</div>
|
|
|
|
|
);
|
2025-04-02 14:03:40 +08:00
|
|
|
};
|