import { useState, useEffect } from "react"; import { conversationService } from "../api/conversationService"; type Conversation = { title: string; id: string; }; type ConversationProps = { conversations: Conversation[]; onSelectConversation: (conversation: Conversation) => void; onCreateNewConversation: () => void; }; export const ConversationList = ({ conversations, onSelectConversation, onCreateNewConversation, }: ConversationProps) => { const [conservations, setConversations] = useState(conversations); useEffect(() => { const loadConversations = async () => { try { const fetchedConversations = await conversationService.getAllConversations(); setConversations( fetchedConversations.map((conversation) => ({ id: conversation.id, title: conversation.name, })), ); } catch (error) { console.error("Failed to load messages:", error); } }; loadConversations(); }, []); return (
{conversation.title}
+ Start a new thread