From b7e45dabad4219480e6b237f4dcc16f77287c7f0 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Mon, 30 Oct 2023 22:22:27 +0700 Subject: [PATCH] Add button new conversation in history list --- web/app/_components/HistoryList/index.tsx | 74 ++++++++++++++++------- 1 file changed, 51 insertions(+), 23 deletions(-) diff --git a/web/app/_components/HistoryList/index.tsx b/web/app/_components/HistoryList/index.tsx index 3cbb482f6..3dab9f411 100644 --- a/web/app/_components/HistoryList/index.tsx +++ b/web/app/_components/HistoryList/index.tsx @@ -1,46 +1,74 @@ import HistoryItem from '../HistoryItem' -import { useEffect } from 'react' +import { Fragment, useEffect } from 'react' import ExpandableHeader from '../ExpandableHeader' -import { useAtomValue } from 'jotai' +import { useAtomValue, useSetAtom } from 'jotai' import { searchAtom } from '@helpers/JotaiWrapper' import useGetUserConversations from '@hooks/useGetUserConversations' import SidebarEmptyHistory from '../SidebarEmptyHistory' import { userConversationsAtom } from '@helpers/atoms/Conversation.atom' import { twMerge } from 'tailwind-merge' +import { Button } from '@uikit' +import { activeAssistantModelAtom, stateModel } from '@helpers/atoms/Model.atom' +import useCreateConversation from '@hooks/useCreateConversation' +import { showingModalNoActiveModel } from '@helpers/atoms/Modal.atom' +import { PlusIcon } from '@heroicons/react/24/outline' const HistoryList: React.FC = () => { const conversations = useAtomValue(userConversationsAtom) const searchText = useAtomValue(searchAtom) const { getUserConversations } = useGetUserConversations() + const activeModel = useAtomValue(activeAssistantModelAtom) + const { requestCreateConvo } = useCreateConversation() + const setShowModalNoActiveModel = useSetAtom(showingModalNoActiveModel) + + const onNewConversationClick = () => { + if (activeModel) { + requestCreateConvo(activeModel) + } else { + setShowModalNoActiveModel(true) + } + } useEffect(() => { getUserConversations() + // eslint-disable-next-line react-hooks/exhaustive-deps }, []) return (
-
    - {conversations.length > 0 ? ( - conversations - .filter( - (e) => - searchText.trim() === '' || - e.name?.toLowerCase().includes(searchText.toLowerCase().trim()) - ) - .map((convo) => ( - - )) - ) : ( - - )} -
+ {conversations.length > 0 ? ( + +
    + {conversations + .filter( + (e) => + searchText.trim() === '' || + e.name + ?.toLowerCase() + .includes(searchText.toLowerCase().trim()) + ) + .map((convo, i) => ( + + ))} +
+ +
+ ) : ( + + )}
) }