import Link from "next/link"; import { useEffect, useState } from "react"; import { useChatStore, useUserStore } from "../../store"; import { Chat, User } from "../../types"; import Icon from "../Icon"; const Sidebar = () => { const userStore = useUserStore(); const chatStore = useChatStore(); const [currentChat, setCurrentChat] = useState(null); useEffect(() => { setCurrentChat(chatStore.currentChat); }, [chatStore.currentChat]); const handleAssistantClick = (user: User) => { for (const chat of chatStore.chatList) { if (chat.userId === user.id) { chatStore.setCurrentChat(chat); return; } } chatStore.createChat(user); }; return (

Assistant list

{userStore.assistantList.map((assistant) => (
handleAssistantClick(assistant)} key={assistant.id} > {assistant.name}
))}
); }; export default Sidebar;