From 758a1215c207a36b2909c7f8b7afe042a70d1b49 Mon Sep 17 00:00:00 2001 From: Mckay Wrigley Date: Wed, 15 Mar 2023 06:04:12 -0600 Subject: [PATCH] mvp --- components/Conversations.tsx | 39 ++++++ components/ModelSelect.tsx | 2 +- components/Sidebar/Sidebar.tsx | 23 +++- pages/index.tsx | 243 ++++++++++++++++++++++----------- types/index.ts | 6 + 5 files changed, 228 insertions(+), 85 deletions(-) create mode 100644 components/Conversations.tsx diff --git a/components/Conversations.tsx b/components/Conversations.tsx new file mode 100644 index 0000000..f4cb529 --- /dev/null +++ b/components/Conversations.tsx @@ -0,0 +1,39 @@ +import { Conversation } from "@/types"; +import { IconMessage, IconTrash } from "@tabler/icons-react"; +import { FC } from "react"; + +interface Props { + conversations: Conversation[]; + selectedConversation: Conversation; + onSelectConversation: (conversation: Conversation) => void; + onDeleteConversation: (conversation: Conversation) => void; +} + +export const Conversations: FC = ({ conversations, selectedConversation, onSelectConversation, onDeleteConversation }) => { + return ( +
+ {conversations.map((conversation, index) => ( +
onSelectConversation(conversation)} + > + +
{conversation.messages[0] ? conversation.messages[0].content : "Empty conversation"}
+ + { + e.stopPropagation(); + onDeleteConversation(conversation); + }} + /> +
+ ))} +
+ ); +}; diff --git a/components/ModelSelect.tsx b/components/ModelSelect.tsx index d092c45..a0199cd 100644 --- a/components/ModelSelect.tsx +++ b/components/ModelSelect.tsx @@ -11,7 +11,7 @@ export const ModelSelect: FC = ({ model, onSelect }) => {